From 11fbbad3ec8b954eba92ee59af10e9e47f4ac9b2 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Mon, 22 May 2023 07:57:41 -0400 Subject: [PATCH 1/2] refactor(bitbucket): use paginated api for comments --- lib/modules/platform/bitbucket/comments.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/modules/platform/bitbucket/comments.ts b/lib/modules/platform/bitbucket/comments.ts index 6aefe689edf3c5..a683b6b8e87932 100644 --- a/lib/modules/platform/bitbucket/comments.ts +++ b/lib/modules/platform/bitbucket/comments.ts @@ -1,8 +1,7 @@ import { logger } from '../../../logger'; import { BitbucketHttp } from '../../../util/http/bitbucket'; import type { EnsureCommentConfig, EnsureCommentRemovalConfig } from '../types'; -import type { Config } from './types'; -import { accumulateValues } from './utils'; +import type { Config, PagedResult } from './types'; const bitbucketHttp = new BitbucketHttp(); @@ -21,9 +20,11 @@ async function getComments( config: CommentsConfig, prNo: number ): Promise { - const comments = await accumulateValues( - `/2.0/repositories/${config.repository}/pullrequests/${prNo}/comments` - ); + const comments = (await bitbucketHttp.getJson>( + `/2.0/repositories/${config.repository}/pullrequests/${prNo}/comments`, { + paginate: true + } + )).body.values; logger.debug(`Found ${comments.length} comments`); return comments; From 41249dd2d03300fc78e47f01f96df0e8c9edb520 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Mon, 22 May 2023 08:22:25 -0400 Subject: [PATCH 2/2] fix linting --- lib/modules/platform/bitbucket/comments.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/modules/platform/bitbucket/comments.ts b/lib/modules/platform/bitbucket/comments.ts index a683b6b8e87932..106a638971530b 100644 --- a/lib/modules/platform/bitbucket/comments.ts +++ b/lib/modules/platform/bitbucket/comments.ts @@ -20,11 +20,14 @@ async function getComments( config: CommentsConfig, prNo: number ): Promise { - const comments = (await bitbucketHttp.getJson>( - `/2.0/repositories/${config.repository}/pullrequests/${prNo}/comments`, { - paginate: true - } - )).body.values; + const comments = ( + await bitbucketHttp.getJson>( + `/2.0/repositories/${config.repository}/pullrequests/${prNo}/comments`, + { + paginate: true, + } + ) + ).body.values; logger.debug(`Found ${comments.length} comments`); return comments;