From d9f5d04e210b69c65a686503265ea2b707f31cd6 Mon Sep 17 00:00:00 2001
From: Adam Setch <adam.setch@outlook.com>
Date: Mon, 22 May 2023 08:43:40 -0400
Subject: [PATCH] refactor(bitbucket): use paginated api for comments (#22348)

---
 lib/modules/platform/bitbucket/comments.ts | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/modules/platform/bitbucket/comments.ts b/lib/modules/platform/bitbucket/comments.ts
index 6aefe689ed..106a638971 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,14 @@ async function getComments(
   config: CommentsConfig,
   prNo: number
 ): Promise<Comment[]> {
-  const comments = await accumulateValues<Comment>(
-    `/2.0/repositories/${config.repository}/pullrequests/${prNo}/comments`
-  );
+  const comments = (
+    await bitbucketHttp.getJson<PagedResult<Comment>>(
+      `/2.0/repositories/${config.repository}/pullrequests/${prNo}/comments`,
+      {
+        paginate: true,
+      }
+    )
+  ).body.values;
 
   logger.debug(`Found ${comments.length} comments`);
   return comments;
-- 
GitLab