add forceFork input to createPullRequest

Signed-off-by: Abel Rodriguez <abelr2613@gmail.com>
This commit is contained in:
Abel Rodriguez
2024-01-24 14:14:06 -06:00
parent bb1360e0a7
commit 1ba7f03f49
2 changed files with 61 additions and 0 deletions
@@ -687,4 +687,57 @@ describe('createPublishGithubPullRequestAction', () => {
});
});
});
describe('with force fork', () => {
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',
forceFork: true,
};
mockDir.setContent({
[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',
files: {
'file.txt': {
content: Buffer.from('Hello there!').toString('base64'),
encoding: 'base64',
mode: '100644',
},
},
},
],
forceFork: true,
});
});
});
});
@@ -135,6 +135,7 @@ export const createPublishGithubPullRequestAction = (
teamReviewers?: string[];
commitMessage?: string;
update?: boolean;
forceFork?: boolean;
}>({
id: 'publish:github:pull-request',
examples,
@@ -217,6 +218,11 @@ export const createPublishGithubPullRequestAction = (
title: 'Update',
description: 'Update pull request if already exists',
},
forceFork: {
type: 'boolean',
title: 'Force Fork',
description: 'Create pull request from a fork',
},
},
},
output: {
@@ -255,6 +261,7 @@ export const createPublishGithubPullRequestAction = (
teamReviewers,
commitMessage,
update,
forceFork,
} = ctx.input;
const { owner, repo, host } = parseRepoUrl(repoUrl, integrations);
@@ -327,6 +334,7 @@ export const createPublishGithubPullRequestAction = (
head: branchName,
draft,
update,
forceFork,
};
if (targetBranchName) {
createOptions.base = targetBranchName;