mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-02 17:13:33 +01:00
Merge remote-tracking branch 'origin/main' into integrate/source-errors
# Conflicts: # public/asset-manifest.json # public/css/all.min.css # public/css/style.css # public/partials/anonymize.htm # public/script/vendor.min.js
This commit is contained in:
commit
c014b3c8cf
22 files changed
+444
-92
No files matched your search
@@ -561,12 +561,10 @@ export default class Repository {
|
||||
await this.markExpired();
|
||||
}
|
||||
}
|
||||
if (
|
||||
this.status == RepositoryStatus.EXPIRED ||
|
||||
this.status == RepositoryStatus.EXPIRING ||
|
||||
this.status == RepositoryStatus.REMOVING ||
|
||||
this.status == RepositoryStatus.REMOVED
|
||||
) {
|
||||
if (this.status == RepositoryStatus.REMOVING || this.status == RepositoryStatus.REMOVED) {
|
||||
throw new AnonymousError("is_removed", { object: this, httpStatus: 410 });
|
||||
}
|
||||
if (this.status == RepositoryStatus.EXPIRED || this.status == RepositoryStatus.EXPIRING) {
|
||||
throw new AnonymousError("repository_expired", {
|
||||
object: this,
|
||||
httpStatus: 410,
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { octokit } from "./GitHubUtils";
|
||||
|
||||
/** One upstream page per request. Search cursors resume within that page. */
|
||||
export async function repositoryPickerPage(token: string, cursor = 0, query = "") {
|
||||
const size = query ? 100 : 20;
|
||||
const page = Math.floor(cursor / size) + 1;
|
||||
const offset = cursor % size;
|
||||
const response = await octokit(token).request("GET /user/repos", {
|
||||
visibility: "all", sort: "full_name", direction: "asc", per_page: size, page,
|
||||
});
|
||||
const items: { id: number; fullName: string }[] = [];
|
||||
let index = offset;
|
||||
for (; index < response.data.length; index++) {
|
||||
const repo = response.data[index];
|
||||
if (!query || repo.full_name.toLowerCase().includes(query.toLowerCase())) {
|
||||
items.push({ id: repo.id, fullName: repo.full_name });
|
||||
if (items.length === 20) { index++; break; }
|
||||
}
|
||||
}
|
||||
const hasNext = index < response.data.length || /rel="next"/.test(response.headers.link || "");
|
||||
return { items, nextCursor: hasNext ? (page - 1) * size + index : null };
|
||||
}
|
||||
Reference in new issue
Block a user