Skip to content

Commit

Permalink
Move Bitbucket PR author filter server-side (#10871)
Browse files Browse the repository at this point in the history
  • Loading branch information
sparhomenko authored Jul 16, 2021
1 parent ec7b085 commit 61f2f65
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/platform/bitbucket/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ Array [
"user-agent": "RenovateBot/0.0.0-semantic-release (https://github.com/renovatebot/renovate)",
},
"method": "GET",
"url": "https://api.bitbucket.org/2.0/repositories/some/repo/pullrequests?state=OPEN&state=MERGED&state=DECLINED&state=SUPERSEDED&pagelen=50",
"url": "https://api.bitbucket.org/2.0/repositories/some/repo/pullrequests?state=OPEN&state=MERGED&state=DECLINED&state=SUPERSEDED&q=author.uuid%3D%2212345%22&pagelen=50",
},
]
`;
Expand Down
9 changes: 1 addition & 8 deletions lib/platform/bitbucket/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,10 @@ describe(getName(), () => {
await initRepoMock(null, null, scope);
scope
.get(
'/2.0/repositories/some/repo/pullrequests?state=OPEN&state=MERGED&state=DECLINED&state=SUPERSEDED&pagelen=50'
'/2.0/repositories/some/repo/pullrequests?state=OPEN&state=MERGED&state=DECLINED&state=SUPERSEDED&q=author.uuid="12345"&pagelen=50'
)
.reply(200, {
values: [
{
id: 2,
author: { uuid: 'abcde' },
source: { branch: { name: 'branch-a' } },
destination: { branch: { name: 'branch-a' } },
state: 'OPEN',
},
{
id: 1,
author: { uuid: '12345' },
Expand Down
12 changes: 4 additions & 8 deletions lib/platform/bitbucket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,11 @@ export async function getPrList(): Promise<Pr[]> {
logger.debug('Retrieving PR list');
let url = `/2.0/repositories/${config.repository}/pullrequests?`;
url += utils.prStates.all.map((state) => 'state=' + state).join('&');
if (renovateUserUuid && !config.ignorePrAuthor) {
url += `&q=author.uuid="${renovateUserUuid}"`;
}
const prs = await utils.accumulateValues(url, undefined, undefined, 50);
config.prList = prs
.filter((pr) => {
const prAuthorId = pr?.author?.uuid;
return renovateUserUuid && prAuthorId && !config.ignorePrAuthor
? renovateUserUuid === prAuthorId
: true;
})
.map(utils.prInfo);
config.prList = prs.map(utils.prInfo);
logger.debug({ length: config.prList.length }, 'Retrieved Pull Requests');
}
return config.prList;
Expand Down

0 comments on commit 61f2f65

Please sign in to comment.