Refactor setting commit params

This commit is contained in:
Peter Evans 2020-07-31 16:57:16 +09:00
parent ee482f51bd
commit ba8309ff9c
2 changed files with 10 additions and 11 deletions

13
dist/index.js vendored
View File

@ -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);

View File

@ -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