Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a --no-verify option to prevent git hooks from being verified #44

Merged
merged 4 commits into from
Jun 2, 2016

Conversation

noahrc
Copy link
Contributor

@noahrc noahrc commented May 26, 2016

Thanks for the awesome tool! We use a git pre-commit hook to test our code before committing and it seems to prevent the last step of standard-version (git tag). This PR adds a --no-verify option to disable git hook verification.

@bcoe
Copy link
Member

bcoe commented May 31, 2016

@noahrc this seems great to me, what do you think @stevemao?

@stevemao
Copy link
Member

Depends on how you see the scope of this module. I personally think it should be consistent with npm-version but looks like it doesn't support this.

But I like this feature. Maybe we could add it to npm-version?

@bcoe
Copy link
Member

bcoe commented May 31, 2016

@stevemao I'll mention the idea to @othiym23 and team, seems like it could be a useful option.

Having said that, I think this is a pretty nice little addition to standard-version, and would help get another team using our tool for their release flow ... my temptation is to add this.

@bcoe
Copy link
Member

bcoe commented Jun 1, 2016

@noahrc mind rebasing with master?

@nexdrew
Copy link
Member

nexdrew commented Jun 1, 2016

@noahrc One small nit from me - can we document the --no-verify option to the CLI help text (by adding the .option() to yargs)?

@bcoe @stevemao Thoughts?

@@ -94,6 +94,17 @@ As long as your git commit messages are conventional and accurate, you no longer

After you cut a release, you can push the new git tag and `npm publish` (or `npm publish --tag next`) when you're ready.

### Prevent Git Hooks

If you use git hooks, like pre-commit, to test your code before committing, you can prevent hooks from being verified during the commit step by passing the `--no-verify` option:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, nice work!

@noahrc
Copy link
Contributor Author

noahrc commented Jun 2, 2016

Thanks, all. I rebased off master and added some CLI help text for no-verify.

@@ -31,6 +31,13 @@ var argv = require('yargs')
default: false,
global: true
})
.option('no-verify', {
alias: 'n',
describe: 'Bypass pre-commit or commit-msg git hooks during the commit phase.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you remove the full-stop?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevemao Not sure what you mean. Do you want Noah to remove the period at the end of the description?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just to be consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok gotcha, that makes sense. Thanks for clarifying. 👍

@nexdrew
Copy link
Member

nexdrew commented Jun 2, 2016

@noahrc Because of the way that yargs (actually yargs-parser) handles boolean flags by interpreting --no-anything to just negate argv.anything without setting argv.noAnything (or its aliases) to true, your -n alias actually doesn't work as is. But I agree that we should keep --no-verify with an -n alias to be consistent with the git commit flags.

To reconcile the difference, I think we should add a check for argv.n to your logic, changing this:

var verify = argv.verify === false ? '--no-verify ' : ''

to this:

var verify = argv.verify === false || argv.n ? '--no-verify ' : ''

According to my tests, that produces the desired behavior.

$ ./index.js
OLD: use --no-verify? false
NEW: use --no-verify? false
$ ./index.js --no-verify
OLD: use --no-verify? true
NEW: use --no-verify? true
$ ./index.js -n
OLD: use --no-verify? false
NEW: use --no-verify? true

@noahrc
Copy link
Contributor Author

noahrc commented Jun 2, 2016

Interesting, thanks for the explanation of how yargs works. I'll make that change and add a test for '-n'.

@stevemao
Copy link
Member

stevemao commented Jun 2, 2016

Because of the way that yargs (actually yargs-parser) handles boolean flags by interpreting --no-anything to just negate argv.anything without setting argv.noAnything (or its aliases) to true

Hmm... A bit counterintuitive and nowadays I tend not to do too much magic to modules. But since it's already doing it, maybe its worth to fix it in yargs-parser? @bcoe

@noahrc
Copy link
Contributor Author

noahrc commented Jun 2, 2016

I went ahead and added the argv.n check, but can revert if yargs-parser changes.

@nexdrew
Copy link
Member

nexdrew commented Jun 2, 2016

I totally forgot about the ability to disable boolean negation in yargs-parser. We could apply the following config to package.json:

  "yargs": {
    "boolean-negation": false
  }

But we'd still have to check for argv.n or argv.noVerify to be true (instead of checking for argv.verify to be false).

Either way, this will now work as is and looks shippable to me. I vote merge. 😎

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 95.294% when pulling b37bc84 on noahrc:master into 178e001 on conventional-changelog:master.

@bcoe bcoe merged commit 026d844 into conventional-changelog:master Jun 2, 2016
@bcoe
Copy link
Member

bcoe commented Jun 2, 2016

@noahrc give this a shot:

npm i standard-version@next

thanks a ton for the contribution.

@noahrc
Copy link
Contributor Author

noahrc commented Jun 3, 2016

works for me!

Thanks for making great open source tools 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants