From ba8309ff9c5fd6dd74e0150cdd257c20da23f010 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Fri, 31 Jul 2020 16:57:16 +0900 Subject: [PATCH] Refactor setting commit params --- dist/index.js | 13 ++++++------- src/create-or-update-branch.ts | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dist/index.js b/dist/index.js index fee807c..687a1b3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1077,12 +1077,11 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName if (yield git.isDirty(true)) { core.info('Uncommitted changes found. Adding a commit.'); yield git.exec(['add', '-A']); - if (signoff == true) { - yield git.commit(['-m', commitMessage, '-s']); - } - else { - yield git.commit(['-m', commitMessage]); + const params = ['-m', commitMessage]; + if (signoff) { + params.push('--signoff'); } + yield git.commit(params); } // Perform fetch and reset the working base // Commits made during the workflow will be removed @@ -1301,6 +1300,7 @@ function run() { commitMessage: core.getInput('commit-message'), committer: core.getInput('committer'), author: core.getInput('author'), + signoff: core.getInput('signoff') === 'true', branch: core.getInput('branch'), branchSuffix: core.getInput('branch-suffix'), base: core.getInput('base'), @@ -1312,8 +1312,7 @@ function run() { reviewers: utils.getInputAsArray('reviewers'), teamReviewers: utils.getInputAsArray('team-reviewers'), milestone: Number(core.getInput('milestone')), - draft: core.getInput('draft') === 'true', - signoff: core.getInput('signoff') === 'true' + draft: core.getInput('draft') === 'true' }; core.debug(`Inputs: ${util_1.inspect(inputs)}`); yield create_pull_request_1.createPullRequest(inputs); diff --git a/src/create-or-update-branch.ts b/src/create-or-update-branch.ts index 6a6435e..700cc14 100644 --- a/src/create-or-update-branch.ts +++ b/src/create-or-update-branch.ts @@ -100,11 +100,11 @@ export async function createOrUpdateBranch( if (await git.isDirty(true)) { core.info('Uncommitted changes found. Adding a commit.') await git.exec(['add', '-A']) - if (signoff == true) { - await git.commit(['-m', commitMessage, '-s']) - } else { - await git.commit(['-m', commitMessage]) + const params = ['-m', commitMessage] + if (signoff) { + params.push('--signoff') } + await git.commit(params) } // Perform fetch and reset the working base