This commit is contained in:
javiertury 2025-01-07 09:11:53 +01:00 committed by GitHub
commit 3d3301fe16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -118,13 +118,16 @@ export class GiteaPrCache {
} }
private async sync(http: GiteaHttp): Promise<GiteaPrCache> { private async sync(http: GiteaHttp): Promise<GiteaPrCache> {
const query = getQueryString({ const urlPath = `${API_PATH}/repos/${this.repo}/pulls`;
const queryParams = {
state: 'all', state: 'all',
sort: 'recentupdate', sort: 'recentupdate',
}); };
let page: number = 1;
const query = getQueryString(queryParams);
let url: string | undefined = let url: string | undefined =
`${API_PATH}/repos/${this.repo}/pulls?${query}`; `${urlPath}?${query}`;
while (url) { while (url) {
const res: HttpResponse<PR[]> = await http.getJson<PR[]>(url, { const res: HttpResponse<PR[]> = await http.getJson<PR[]>(url, {
@ -133,11 +136,17 @@ export class GiteaPrCache {
}); });
const needNextPage = this.reconcile(res.body); const needNextPage = this.reconcile(res.body);
if (!needNextPage) { const nextUrl: string | undefined = parseLinkHeader(res.headers.link)?.next?.url;
if (!needNextPage || res.body.length === 0 || nextUrl === undefined) {
break; break;
} }
url = parseLinkHeader(res.headers.link)?.next?.url; page += 1;
const query = getQueryString({
...queryParams,
page
});
url = `${urlPath}?${query}`;
} }
this.updateItems(); this.updateItems();