Skip to content

Commit

Permalink
refactor(bitbucket): use paginated api for comments (#22348)
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed May 22, 2023
1 parent 947babe commit d9f5d04
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions 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();

Expand All @@ -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;
Expand Down

0 comments on commit d9f5d04

Please sign in to comment.