Skip to content

Commit

Permalink
feat(version): add --signoff git flag
Browse files Browse the repository at this point in the history
- ref Lerna PR [#2897](lerna/lerna#2897)
  • Loading branch information
ghiscoding committed Feb 11, 2022
1 parent fa71be0 commit 8eea85a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/cli/src/versionCommandOptions.ts
Expand Up @@ -173,6 +173,10 @@ export const versionCommandOptions = {
group: 'Version Command Options:',
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`.',
group: 'Version Command Options:',
Expand Down
7 changes: 7 additions & 0 deletions packages/version/README.md
Expand Up @@ -96,6 +96,7 @@ Running `ws-roller version --conventional-commits` without the above flags will
- [`--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)
Expand Down Expand Up @@ -441,6 +442,12 @@ ws-roller version prepatch --preid next
When run with this flag, `ws-roller 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/cli/v8/using-npm/config#sign-git-commit) of the same name.
Expand Down
6 changes: 5 additions & 1 deletion packages/version/src/lib/git-commit.ts
Expand Up @@ -9,7 +9,7 @@ import { exec } from '@ws-conventional-version-roller/core';
* @param {{ amend: boolean; commitHooks: boolean; signGitCommit: boolean; }} gitOpts
* @param {import('@lerna/child-process').ExecOpts} opts
*/
export function gitCommit(message, { amend, commitHooks, signGitCommit }, opts, gitDryRun = false) {
export function gitCommit(message, { amend, commitHooks, signGitCommit, signoffGitCommit }, opts, gitDryRun = false) {
log.silly('gitCommit', message);
const args = ['commit'];

Expand All @@ -21,6 +21,10 @@ export 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
2 changes: 2 additions & 0 deletions packages/version/src/versionCommand.ts
Expand Up @@ -82,6 +82,7 @@ export class VersionCommand extends Command {
granularPathspec = true,
push = true,
signGitCommit,
signoffGitCommit,
signGitTag,
forceGitTag,
tagVersionPrefix = 'v',
Expand Down Expand Up @@ -110,6 +111,7 @@ export class VersionCommand extends Command {
commitHooks,
granularPathspec,
signGitCommit,
signoffGitCommit,
signGitTag,
forceGitTag,
};
Expand Down

0 comments on commit 8eea85a

Please sign in to comment.