Skip to content

Commit

Permalink
feat(version): add --signoff git flag
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed May 6, 2021
1 parent 6cb8ab2 commit 292ab0b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions commands/version/__tests__/git-commit.test.js
Expand Up @@ -43,4 +43,10 @@ describe("git commit", () => {
await gitCommit("nice", { signGitCommit: true }, opts);
expect(childProcess.exec).toHaveBeenLastCalledWith("git", ["commit", "--gpg-sign", "-m", "nice"], opts);
});

test("--signoff-git-commit", async () => {
const opts = { cwd: "signed-off" };
await gitCommit("nice", { signoffGitCommit: true }, opts);
expect(childProcess.exec).toHaveBeenLastCalledWith("git", ["commit", "--signoff", "-m", "nice"], opts);
});
});
4 changes: 4 additions & 0 deletions commands/version/command.js
Expand Up @@ -146,6 +146,10 @@ exports.builder = (yargs, composed) => {
describe: "Pass the `--gpg-sign` flag to `git commit`.",
type: "boolean",
},
"signoff-git-commit": {
describe: "Pass the `--signoff` flag to `git commit`.",
type: "boolean",
},
"sign-git-tag": {
describe: "Pass the `--sign` flag to `git tag`.",
type: "boolean",
Expand Down
2 changes: 2 additions & 0 deletions commands/version/index.js
Expand Up @@ -65,6 +65,7 @@ class VersionCommand extends Command {
granularPathspec = true,
push = true,
signGitCommit,
signoffGitCommit,
signGitTag,
forceGitTag,
tagVersionPrefix = "v",
Expand Down Expand Up @@ -93,6 +94,7 @@ class VersionCommand extends Command {
commitHooks,
granularPathspec,
signGitCommit,
signoffGitCommit,
signGitTag,
forceGitTag,
};
Expand Down
6 changes: 5 additions & 1 deletion commands/version/lib/git-commit.js
Expand Up @@ -12,7 +12,7 @@ module.exports.gitCommit = gitCommit;
* @param {{ amend: boolean; commitHooks: boolean; signGitCommit: boolean; }} gitOpts
* @param {import("@lerna/child-process").ExecOpts} opts
*/
function gitCommit(message, { amend, commitHooks, signGitCommit }, opts) {
function gitCommit(message, { amend, commitHooks, signGitCommit, signoffGitCommit }, opts) {
log.silly("gitCommit", message);
const args = ["commit"];

Expand All @@ -24,6 +24,10 @@ function gitCommit(message, { amend, commitHooks, signGitCommit }, opts) {
args.push("--gpg-sign");
}

if (signoffGitCommit) {
args.push("--signoff");
}

if (amend) {
args.push("--amend", "--no-edit");
} else if (message.indexOf(EOL) > -1) {
Expand Down

0 comments on commit 292ab0b

Please sign in to comment.