Support merge request labels in publish:gitlab:merge-request
Signed-off-by: Matt Benson <gudnabrsam@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
|
||||
---
|
||||
|
||||
Support merge request labels in publish:gitlab:merge-request
|
||||
@@ -206,6 +206,7 @@ export const createPublishGitlabMergeRequestAction: (options: {
|
||||
assignee?: string | undefined;
|
||||
reviewers?: string[] | undefined;
|
||||
assignReviewersFromApprovalRules?: boolean | undefined;
|
||||
labels?: string | string[] | undefined;
|
||||
},
|
||||
{
|
||||
targetBranchName: string;
|
||||
|
||||
@@ -1446,4 +1446,66 @@ describe('createGitLabMergeRequest', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('with labels', () => {
|
||||
it('handles single label', async () => {
|
||||
const input = {
|
||||
repoUrl: 'gitlab.com?repo=repo&owner=owner',
|
||||
title: 'Create my new MR',
|
||||
branchName: 'new-mr',
|
||||
description: 'MR description',
|
||||
commitAction: 'skip',
|
||||
labels: 'single-label',
|
||||
};
|
||||
const ctx = createMockActionContext({ input, workspacePath });
|
||||
await instance.handler(ctx);
|
||||
|
||||
expect(mockGitlabClient.Branches.create).toHaveBeenCalledWith(
|
||||
'owner/repo',
|
||||
'new-mr',
|
||||
'main',
|
||||
);
|
||||
expect(mockGitlabClient.Commits.create).not.toHaveBeenCalled();
|
||||
expect(mockGitlabClient.MergeRequests.create).toHaveBeenCalledWith(
|
||||
'owner/repo',
|
||||
'new-mr',
|
||||
'main',
|
||||
'Create my new MR',
|
||||
{
|
||||
description: 'MR description',
|
||||
removeSourceBranch: false,
|
||||
labels: 'single-label',
|
||||
},
|
||||
);
|
||||
});
|
||||
it('handles array of labels', async () => {
|
||||
const input = {
|
||||
repoUrl: 'gitlab.com?repo=repo&owner=owner',
|
||||
title: 'Create my new MR',
|
||||
branchName: 'new-mr',
|
||||
description: 'MR description',
|
||||
commitAction: 'skip',
|
||||
labels: ['foo', 'bar', 'baz'],
|
||||
};
|
||||
const ctx = createMockActionContext({ input, workspacePath });
|
||||
await instance.handler(ctx);
|
||||
|
||||
expect(mockGitlabClient.Branches.create).toHaveBeenCalledWith(
|
||||
'owner/repo',
|
||||
'new-mr',
|
||||
'main',
|
||||
);
|
||||
expect(mockGitlabClient.Commits.create).not.toHaveBeenCalled();
|
||||
expect(mockGitlabClient.MergeRequests.create).toHaveBeenCalledWith(
|
||||
'owner/repo',
|
||||
'new-mr',
|
||||
'main',
|
||||
'Create my new MR',
|
||||
{
|
||||
description: 'MR description',
|
||||
removeSourceBranch: false,
|
||||
labels: ['foo', 'bar', 'baz'],
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -222,6 +222,12 @@ _deprecated_: \`projectid\` passed as query parameters in the \`repoUrl\``,
|
||||
.describe(
|
||||
'Automatically assign reviewers from the approval rules of the MR. Includes `CODEOWNERS`',
|
||||
),
|
||||
labels: z =>
|
||||
z
|
||||
.string()
|
||||
.or(z.string().array())
|
||||
.optional()
|
||||
.describe('Labels with which to tag the created merge request'),
|
||||
},
|
||||
output: {
|
||||
targetBranchName: z =>
|
||||
@@ -245,6 +251,7 @@ _deprecated_: \`projectid\` passed as query parameters in the \`repoUrl\``,
|
||||
sourcePath,
|
||||
title,
|
||||
token,
|
||||
labels,
|
||||
} = ctx.input;
|
||||
|
||||
const { owner, repo, project } = parseRepoUrl(repoUrl, integrations);
|
||||
@@ -453,6 +460,7 @@ _deprecated_: \`projectid\` passed as query parameters in the \`repoUrl\``,
|
||||
: false,
|
||||
assigneeId,
|
||||
reviewerIds,
|
||||
labels,
|
||||
},
|
||||
);
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user