Add commit message as parameter

test as well

Signed-off-by: pballandras@coveo.com <pballandras@coveo.com>
This commit is contained in:
pballandras@coveo.com
2023-03-21 15:10:17 -04:00
parent 391b7fbd28
commit 0579396bce
2 changed files with 60 additions and 1 deletions
@@ -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',
},
},
},
],
});
});
});
});
@@ -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 PR 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,