diff --git a/commands/version/__tests__/git-commit.test.js b/commands/version/__tests__/git-commit.test.js index 0d0c3b62dc3..0e21bb08010 100644 --- a/commands/version/__tests__/git-commit.test.js +++ b/commands/version/__tests__/git-commit.test.js @@ -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); + }); }); diff --git a/commands/version/command.js b/commands/version/command.js index d82bd24c856..7b0f55b70b2 100644 --- a/commands/version/command.js +++ b/commands/version/command.js @@ -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", diff --git a/commands/version/index.js b/commands/version/index.js index 3fcea7cf5d2..8c3a12e45a7 100644 --- a/commands/version/index.js +++ b/commands/version/index.js @@ -65,6 +65,7 @@ class VersionCommand extends Command { granularPathspec = true, push = true, signGitCommit, + signoffGitCommit, signGitTag, forceGitTag, tagVersionPrefix = "v", @@ -93,6 +94,7 @@ class VersionCommand extends Command { commitHooks, granularPathspec, signGitCommit, + signoffGitCommit, signGitTag, forceGitTag, }; diff --git a/commands/version/lib/git-commit.js b/commands/version/lib/git-commit.js index 42ea41a1359..f92ac03b94b 100644 --- a/commands/version/lib/git-commit.js +++ b/commands/version/lib/git-commit.js @@ -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"]; @@ -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) {