Merge pull request #17018 from pballandras/feature/add-commit-message-parameter
Allow custom commit message when publishing a GitHub Pull Request
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend': minor
|
||||
---
|
||||
|
||||
Allow for a commit message to differ from the PR title when publishing a GitHub pull request.
|
||||
@@ -559,6 +559,7 @@ export const createPublishGithubPullRequestAction: (
|
||||
token?: string | undefined;
|
||||
reviewers?: string[] | undefined;
|
||||
teamReviewers?: string[] | undefined;
|
||||
commitMessage?: string | undefined;
|
||||
},
|
||||
JsonObject
|
||||
>;
|
||||
|
||||
+52
@@ -545,4 +545,56 @@ describe('createPublishGithubPullRequestAction', () => {
|
||||
expect(ctx.output).toHaveBeenCalledWith('pullRequestNumber', 123);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with commit message', () => {
|
||||
let input: GithubPullRequestActionInput;
|
||||
let ctx: ActionContext<GithubPullRequestActionInput>;
|
||||
|
||||
beforeEach(() => {
|
||||
input = {
|
||||
repoUrl: 'github.com?owner=myorg&repo=myrepo',
|
||||
title: 'Create my new app',
|
||||
branchName: 'new-app',
|
||||
description: 'This PR is really good',
|
||||
commitMessage: 'Create my new app, but in the commit message',
|
||||
};
|
||||
|
||||
mockFs({
|
||||
[workspacePath]: { 'file.txt': 'Hello there!' },
|
||||
});
|
||||
|
||||
ctx = {
|
||||
createTemporaryDirectory: jest.fn(),
|
||||
output: jest.fn(),
|
||||
logger: getRootLogger(),
|
||||
logStream: new Writable(),
|
||||
input,
|
||||
workspacePath,
|
||||
};
|
||||
});
|
||||
|
||||
it('creates a pull request', async () => {
|
||||
await instance.handler(ctx);
|
||||
|
||||
expect(fakeClient.createPullRequest).toHaveBeenCalledWith({
|
||||
owner: 'myorg',
|
||||
repo: 'myrepo',
|
||||
title: 'Create my new app',
|
||||
head: 'new-app',
|
||||
body: 'This PR is really good',
|
||||
changes: [
|
||||
{
|
||||
commit: 'Create my new app, but in the commit message',
|
||||
files: {
|
||||
'file.txt': {
|
||||
content: Buffer.from('Hello there!').toString('base64'),
|
||||
encoding: 'base64',
|
||||
mode: '100644',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+8
-1
@@ -136,6 +136,7 @@ export const createPublishGithubPullRequestAction = (
|
||||
token?: string;
|
||||
reviewers?: string[];
|
||||
teamReviewers?: string[];
|
||||
commitMessage?: string;
|
||||
}>({
|
||||
id: 'publish:github:pull-request',
|
||||
schema: {
|
||||
@@ -202,6 +203,11 @@ export const createPublishGithubPullRequestAction = (
|
||||
description:
|
||||
'The teams that will be added as reviewers to the pull request',
|
||||
},
|
||||
commitMessage: {
|
||||
type: 'string',
|
||||
title: 'Commit Message',
|
||||
description: 'The commit message for the pull request commit',
|
||||
},
|
||||
},
|
||||
},
|
||||
output: {
|
||||
@@ -233,6 +239,7 @@ export const createPublishGithubPullRequestAction = (
|
||||
token: providedToken,
|
||||
reviewers,
|
||||
teamReviewers,
|
||||
commitMessage,
|
||||
} = ctx.input;
|
||||
|
||||
const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);
|
||||
@@ -298,7 +305,7 @@ export const createPublishGithubPullRequestAction = (
|
||||
changes: [
|
||||
{
|
||||
files,
|
||||
commit: title,
|
||||
commit: commitMessage ?? title,
|
||||
},
|
||||
],
|
||||
body: description,
|
||||
|
||||
Reference in New Issue
Block a user