From 86e0500023d15dff18e9f2409437611b52444aa3 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 16 May 2023 15:56:52 -0400 Subject: [PATCH 1/3] refactor: use paginated getjson --- lib/modules/platform/bitbucket/index.spec.ts | 2 +- lib/modules/platform/bitbucket/index.ts | 11 ++++++++--- lib/modules/platform/bitbucket/types.ts | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/modules/platform/bitbucket/index.spec.ts b/lib/modules/platform/bitbucket/index.spec.ts index 70a93df243c374..2768f9132a0580 100644 --- a/lib/modules/platform/bitbucket/index.spec.ts +++ b/lib/modules/platform/bitbucket/index.spec.ts @@ -127,7 +127,7 @@ describe('modules/platform/bitbucket/index', () => { it('returns repos', async () => { httpMock .scope(baseUrl) - .get('/2.0/repositories?role=contributor&pagelen=100') + .get('/2.0/repositories?role=contributor') .reply(200, { values: [{ full_name: 'foo/bar' }, { full_name: 'some/repo' }], }); diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index b12eb09a114dae..1cc41beddacd66 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -114,9 +114,14 @@ export async function initPlatform({ export async function getRepos(): Promise { logger.debug('Autodiscovering Bitbucket Cloud repositories'); try { - const repos = await utils.accumulateValues<{ full_name: string }>( - `/2.0/repositories/?role=contributor` - ); + const repos = ( + await bitbucketHttp.getJson>( + `/2.0/repositories/?role=contributor`, + { + paginate: true, + } + ) + ).body.values; return repos.map((repo) => repo.full_name); } catch (err) /* istanbul ignore next */ { logger.error({ err }, `bitbucket getRepos error`); diff --git a/lib/modules/platform/bitbucket/types.ts b/lib/modules/platform/bitbucket/types.ts index 0ffb4b9623cb77..d11477412b963b 100644 --- a/lib/modules/platform/bitbucket/types.ts +++ b/lib/modules/platform/bitbucket/types.ts @@ -62,6 +62,7 @@ export interface RepoInfoBody { mainbranch: { name: string }; has_issues: boolean; uuid: string; + full_name: string; } export interface PrResponse { From bb63eef749997c19016d0479e5c9b9d559f9160f Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Tue, 16 May 2023 16:49:43 -0400 Subject: [PATCH 2/3] add pagelen back --- lib/modules/platform/bitbucket/index.spec.ts | 2 +- lib/modules/platform/bitbucket/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/modules/platform/bitbucket/index.spec.ts b/lib/modules/platform/bitbucket/index.spec.ts index 2768f9132a0580..70a93df243c374 100644 --- a/lib/modules/platform/bitbucket/index.spec.ts +++ b/lib/modules/platform/bitbucket/index.spec.ts @@ -127,7 +127,7 @@ describe('modules/platform/bitbucket/index', () => { it('returns repos', async () => { httpMock .scope(baseUrl) - .get('/2.0/repositories?role=contributor') + .get('/2.0/repositories?role=contributor&pagelen=100') .reply(200, { values: [{ full_name: 'foo/bar' }, { full_name: 'some/repo' }], }); diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index 1cc41beddacd66..013b3b34f422e6 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -116,7 +116,7 @@ export async function getRepos(): Promise { try { const repos = ( await bitbucketHttp.getJson>( - `/2.0/repositories/?role=contributor`, + `/2.0/repositories/?role=contributor&pagelen=100`, { paginate: true, } From d31dd2315aeff8e76bf671f39109cb0f23d96674 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 17 May 2023 11:05:25 -0400 Subject: [PATCH 3/3] update url --- lib/modules/platform/bitbucket/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index 013b3b34f422e6..1cc41beddacd66 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -116,7 +116,7 @@ export async function getRepos(): Promise { try { const repos = ( await bitbucketHttp.getJson>( - `/2.0/repositories/?role=contributor&pagelen=100`, + `/2.0/repositories/?role=contributor`, { paginate: true, }