diff --git a/commands/version/README.md b/commands/version/README.md index e78ce3b571..f30c5ec5a7 100644 --- a/commands/version/README.md +++ b/commands/version/README.md @@ -71,6 +71,7 @@ Running `lerna version --conventional-commits` without the above flags will rele - [`--no-private`](#--no-private) - [`--no-push`](#--no-push) - [`--preid`](#--preid) + - [`--signoff-git-commit`](#--signoff-git-commit) - [`--sign-git-commit`](#--sign-git-commit) - [`--sign-git-tag`](#--sign-git-tag) - [`--force-git-tag`](#--force-git-tag) @@ -212,8 +213,8 @@ When run with this flag, `lerna version` will release with bumped prerelease ver ```sh Changes: - - major: 1.0.0-alpha.0 => 2.0.0-alpha.0 - - minor: 1.0.0-alpha.0 => 1.1.0-alpha.0 + - major: 1.0.0-alpha.0 => 2.0.0-alpha.0 + - minor: 1.0.0-alpha.0 => 1.1.0-alpha.0 - patch: 1.0.0-alpha.0 => 1.0.1-alpha.0 ``` @@ -412,6 +413,12 @@ lerna version prepatch --preid next When run with this flag, `lerna version` will increment `premajor`, `preminor`, `prepatch`, or `prerelease` semver bumps using the specified [prerelease identifier](http://semver.org/#spec-item-9). +### `--signoff-git-commit` + +Adds the `--signoff` flag to the git commit done by lerna version when executed. + +> Note: This is different from `--sign-git-commit` which is about gpg signatures. + ### `--sign-git-commit` This option is analogous to the `npm version` [option](https://docs.npmjs.com/misc/config#sign-git-commit) of the same name. diff --git a/commands/version/__tests__/git-commit.test.js b/commands/version/__tests__/git-commit.test.js index 7b16762de0..b278c94108 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 80b9c6e727..dee6d6e76c 100644 --- a/commands/version/command.js +++ b/commands/version/command.js @@ -150,6 +150,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 a6bfa7d5d6..8f210e827f 100644 --- a/commands/version/index.js +++ b/commands/version/index.js @@ -68,6 +68,7 @@ class VersionCommand extends Command { granularPathspec = true, push = true, signGitCommit, + signoffGitCommit, signGitTag, forceGitTag, tagVersionPrefix = "v", @@ -96,6 +97,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 3be00a68f5..8cc9652dbf 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) {