From e4c00137feef5e243845945d6f91284be16e9db3 Mon Sep 17 00:00:00 2001 From: Keunhong Lee Date: Wed, 18 May 2022 06:46:22 +0000 Subject: [PATCH] feat: add option to choose between force and force-with-lease --- action.yml | 3 +++ dist/index.js | 5 +++-- src/create-pull-request.ts | 3 ++- src/main.ts | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 4cb37f6..fa5f7ce 100644 --- a/action.yml +++ b/action.yml @@ -69,6 +69,9 @@ inputs: draft: description: 'Create a draft pull request. It is not possible to change draft status after creation except through the web interface' default: false + force: + description: 'Force push the changes even if the current branch is referenced by others.' + default: false outputs: pull-request-number: description: 'The pull request number' diff --git a/dist/index.js b/dist/index.js index 2cfbc0c..d0244b8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -393,7 +393,7 @@ function createPullRequest(inputs) { // The branch was created or updated core.startGroup(`Pushing pull request branch to '${branchRemoteName}/${inputs.branch}'`); yield git.push([ - '--force-with-lease', + inputs.force ? '--force' : '--force-with-lease', branchRemoteName, `HEAD:refs/heads/${inputs.branch}` ]); @@ -1109,7 +1109,8 @@ function run() { reviewers: utils.getInputAsArray('reviewers'), teamReviewers: utils.getInputAsArray('team-reviewers'), milestone: Number(core.getInput('milestone')), - draft: core.getBooleanInput('draft') + draft: core.getBooleanInput('draft'), + force: core.getBooleanInput('force') }; core.debug(`Inputs: ${(0, util_1.inspect)(inputs)}`); yield (0, create_pull_request_1.createPullRequest)(inputs); diff --git a/src/create-pull-request.ts b/src/create-pull-request.ts index 81caa88..465e4bc 100644 --- a/src/create-pull-request.ts +++ b/src/create-pull-request.ts @@ -30,6 +30,7 @@ export interface Inputs { teamReviewers: string[] milestone: number draft: boolean + force: boolean } export async function createPullRequest(inputs: Inputs): Promise { @@ -185,7 +186,7 @@ export async function createPullRequest(inputs: Inputs): Promise { `Pushing pull request branch to '${branchRemoteName}/${inputs.branch}'` ) await git.push([ - '--force-with-lease', + inputs.force ? '--force' : '--force-with-lease', branchRemoteName, `HEAD:refs/heads/${inputs.branch}` ]) diff --git a/src/main.ts b/src/main.ts index f3d9171..6b8837a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,7 +25,8 @@ async function run(): Promise { reviewers: utils.getInputAsArray('reviewers'), teamReviewers: utils.getInputAsArray('team-reviewers'), milestone: Number(core.getInput('milestone')), - draft: core.getBooleanInput('draft') + draft: core.getBooleanInput('draft'), + force: core.getBooleanInput('force') } core.debug(`Inputs: ${inspect(inputs)}`)