feat: add reviewers input for bitbucket server pr
This doesn't include default-reviewers because those require a separate semi-official API call to get, which I didn't want to implement for now. Signed-off-by: RedlineTriad <39059512+RedlineTriad@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-bitbucket-server': minor
|
||||
---
|
||||
|
||||
Add `reviewers` input parameter to `publish:bitbucketServer:pull-request`
|
||||
@@ -44,6 +44,7 @@ export function createPublishBitbucketServerPullRequestAction(options: {
|
||||
description?: string | undefined;
|
||||
targetBranch?: string | undefined;
|
||||
sourceBranch: string;
|
||||
reviewers?: string[] | undefined;
|
||||
token?: string | undefined;
|
||||
gitAuthorName?: string | undefined;
|
||||
gitAuthorEmail?: string | undefined;
|
||||
|
||||
+6
-1
@@ -366,7 +366,7 @@ describe('publish:bitbucketServer:pull-request', () => {
|
||||
});
|
||||
|
||||
it(`should ${examples[4].description}`, async () => {
|
||||
expect.assertions(7);
|
||||
expect.assertions(8);
|
||||
server.use(
|
||||
rest.get(
|
||||
'https://no-credentials.bitbucket.com/rest/api/1.0/projects/project/repos/repo/branches',
|
||||
@@ -389,6 +389,7 @@ describe('publish:bitbucketServer:pull-request', () => {
|
||||
toRef: { displayId: string };
|
||||
fromRef: { displayId: string };
|
||||
description: string;
|
||||
reviewers: [{ user: { name: string } }];
|
||||
};
|
||||
expect(requestBody.title).toBe('My pull request');
|
||||
expect(requestBody.fromRef.displayId).toBe('my-feature-branch');
|
||||
@@ -396,6 +397,10 @@ describe('publish:bitbucketServer:pull-request', () => {
|
||||
expect(requestBody.description).toBe(
|
||||
'This is a detailed description of my pull request',
|
||||
);
|
||||
expect(requestBody.reviewers).toEqual([
|
||||
{ user: { name: 'reviewer1' } },
|
||||
{ user: { name: 'reviewer2' } },
|
||||
]);
|
||||
expect(req.headers.get('Authorization')).toBe(
|
||||
`Bearer ${yaml.parse(examples[4].example).steps[0].input.token}`,
|
||||
);
|
||||
|
||||
+1
@@ -107,6 +107,7 @@ export const examples: TemplateExample[] = [
|
||||
sourceBranch: 'my-feature-branch',
|
||||
targetBranch: 'development',
|
||||
description: 'This is a detailed description of my pull request',
|
||||
reviewers: ['reviewer1', 'reviewer2'],
|
||||
token: 'my-auth-token',
|
||||
gitAuthorName: 'test-user',
|
||||
gitAuthorEmail: 'test-user@sample.com',
|
||||
|
||||
+15
@@ -54,6 +54,7 @@ const createPullRequest = async (opts: {
|
||||
latestChangeset: string;
|
||||
isDefault: boolean;
|
||||
};
|
||||
reviewers?: string[];
|
||||
authorization: string;
|
||||
apiBaseUrl: string;
|
||||
}) => {
|
||||
@@ -64,6 +65,7 @@ const createPullRequest = async (opts: {
|
||||
description,
|
||||
toRef,
|
||||
fromRef,
|
||||
reviewers,
|
||||
authorization,
|
||||
apiBaseUrl,
|
||||
} = opts;
|
||||
@@ -80,6 +82,7 @@ const createPullRequest = async (opts: {
|
||||
locked: true,
|
||||
toRef: toRef,
|
||||
fromRef: fromRef,
|
||||
reviewers: reviewers?.map(reviewer => ({ user: { name: reviewer } })),
|
||||
}),
|
||||
headers: {
|
||||
Authorization: authorization,
|
||||
@@ -253,6 +256,7 @@ export function createPublishBitbucketServerPullRequestAction(options: {
|
||||
description?: string;
|
||||
targetBranch?: string;
|
||||
sourceBranch: string;
|
||||
reviewers?: string[];
|
||||
token?: string;
|
||||
gitAuthorName?: string;
|
||||
gitAuthorEmail?: string;
|
||||
@@ -288,6 +292,15 @@ export function createPublishBitbucketServerPullRequestAction(options: {
|
||||
type: 'string',
|
||||
description: 'Branch of repository to copy changes from',
|
||||
},
|
||||
reviewers: {
|
||||
title: 'Pull Request Reviewers',
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description:
|
||||
'The usernames of reviewers that will be added to the pull request',
|
||||
},
|
||||
token: {
|
||||
title: 'Authorization Token',
|
||||
type: 'string',
|
||||
@@ -323,6 +336,7 @@ export function createPublishBitbucketServerPullRequestAction(options: {
|
||||
description,
|
||||
targetBranch,
|
||||
sourceBranch,
|
||||
reviewers,
|
||||
gitAuthorName,
|
||||
gitAuthorEmail,
|
||||
} = ctx.input;
|
||||
@@ -473,6 +487,7 @@ export function createPublishBitbucketServerPullRequestAction(options: {
|
||||
description,
|
||||
toRef,
|
||||
fromRef,
|
||||
reviewers,
|
||||
authorization,
|
||||
apiBaseUrl,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user