Skip to content
Snippets Groups Projects
Commit 6490f1be authored by Michael Kriese's avatar Michael Kriese Committed by Rhys Arkins
Browse files

feat(bitbucket-server): fetch only own pr's (#4044)

parent 3d04c696
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,8 @@ interface BbsConfig {
storage: GitStorage;
prVersions: Map<number, number>;
username: string;
}
let config: BbsConfig = {} as any;
......@@ -115,6 +117,7 @@ export async function initRepo({
gitPrivateKey,
repository,
prVersions: new Map<number, number>(),
username: opts!.username,
} as any;
/* istanbul ignore else */
......@@ -623,8 +626,13 @@ export async function getPrList(_args?: any) {
logger.debug(`getPrList()`);
// istanbul ignore next
if (!config.prList) {
const query = new URLSearchParams({
state: 'ALL',
'role.1': 'AUTHOR',
'username.1': config.username,
}).toString();
const values = await utils.accumulateValues(
`./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests?state=ALL&limit=100`
`./rest/api/1.0/projects/${config.projectKey}/repos/${config.repositorySlug}/pull-requests?${query}`
);
config.prList = values.map(utils.prInfo);
......
......@@ -259,7 +259,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -490,7 +490,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -519,7 +519,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -534,7 +534,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -570,7 +570,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
Array [
......@@ -961,7 +961,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -1713,7 +1713,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -1944,7 +1944,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -1973,7 +1973,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -1988,7 +1988,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......@@ -2024,7 +2024,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
Array [
......@@ -2415,7 +2415,7 @@ Array [
"./rest/api/1.0/projects/SOME/repos/repo/branches/default",
],
Array [
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100",
"./rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100",
undefined,
],
]
......
......@@ -154,7 +154,7 @@ function generateServerResponses(endpoint) {
[`${endpoint}/rest/api/1.0/projects/SOME/repos/repo/pull-requests`]: {
POST: generatePR(endpoint, 'SOME', 'repo'),
},
[`${endpoint}/rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&limit=100`]: {
[`${endpoint}/rest/api/1.0/projects/SOME/repos/repo/pull-requests?state=ALL&role.1=AUTHOR&username.1=abc&limit=100`]: {
GET: {
isLastPage: true,
values: [generatePR(endpoint, 'SOME', 'repo')],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment