Skip to content

Commit

Permalink
fix(gitea): use endpoint for pr cache pagination (#34022)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Feb 4, 2025
1 parent 48b90cc commit f7dcb3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/modules/platform/gitea/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,13 @@ describe('modules/platform/gitea/index', () => {
.scope('https://gitea.com/api/v1')
.get('/repos/some/repo/pulls')
.query({ state: 'all', sort: 'recentupdate' })
.reply(200, mockPRs);
.reply(200, mockPRs.slice(0, 2), {
// test correct pagination handling, domain should be ignored
link: '<https://domain.test/api/v1/repos/some/repo/pulls?state=all&sort=recentupdate&page=2>; rel="next",<https://domain.test/api/v1/repos/some/repo/pulls?state=all&sort=recentupdate&page=4512>; rel="last"',
})
.get('/repos/some/repo/pulls')
.query({ state: 'all', sort: 'recentupdate', page: 2 })
.reply(200, mockPRs.slice(2));
await initFakePlatform(scope);
await initFakeRepo(scope);

Expand Down
5 changes: 3 additions & 2 deletions lib/modules/platform/gitea/pr-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as memCache from '../../../util/cache/memory';
import { getCache } from '../../../util/cache/repository';
import type { GiteaHttp } from '../../../util/http/gitea';
import type { HttpResponse } from '../../../util/http/types';
import { getQueryString, parseLinkHeader } from '../../../util/url';
import { getQueryString, parseLinkHeader, parseUrl } from '../../../util/url';
import type { Pr } from '../types';
import type { GiteaPrCacheData, PR } from './types';
import { API_PATH, toRenovatePR } from './utils';
Expand Down Expand Up @@ -149,7 +149,8 @@ export class GiteaPrCache {
break;
}

url = parseLinkHeader(res.headers.link)?.next?.url;
const uri = parseUrl(parseLinkHeader(res.headers.link)?.next?.url);
url = uri ? `${uri.pathname}${uri.search}` : undefined;
}

this.updateItems();
Expand Down

0 comments on commit f7dcb3c

Please sign in to comment.