[Question] commitizen and standard-version together doesn't work (prepare-commit-msg hook can't be skipped)
See original GitHub issueHi,
I have the following issue, which was somehow discussed in the PR of the feature “feat(cli): Implement --hook option for git hooks integration”:
The Problem
When using the proposed hook solution together with husky, I am not able to skip the git hooks when using standard-version’s release command (see command here).
What I do
Basically, this is what I have and do (used in my react-component-catalog package):
// package.json
"scripts": {
"release": "standard-version"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"prepare-commit-msg": "exec < /dev/tty && git cz --hook"
}
},
Whenever I release something, I execute one of these commands:
npm run release -- --no-verify
# or
npx standard-version --no-verify
This results in the following error:
What I expect and need
I want to be able to use commitizen together with standard-version when creating a new release.
How? Either it would be great to tell the git cz
command to skip interactive mode or entirely for this specific task, or I should use another hook (which I have not yet tested though).
Whatever is better, I am happy if someone can assist me here. 👍
Hints, Links etc.
During my research I stumbled upon an issue raised in the husky package. He wanted to create “(…) a custom prepare-commit-msg hook that appends an ID to the commit msg.” and also had troubles skipping it.
He got a response containing the following hint:
commit-msg hook better suits your needs.
Because prepare-commit-msg
does not allow --no-verify
…
prepare-commit-msg […] The purpose of the hook is to edit the message file in place, and it is not suppressed by the
--no-verify
option.commit-msg […] can be bypassed with the
--no-verify
option. […] It can also be used to refuse the commit after inspecting the message file.
https://git-scm.com/docs/githooks#_prepare_commit_msg
Does that mean I should use commit-msg
instead to make this work? But then people are not enforced anymore to use commitizen…
Thank you for your help!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:11 (4 by maintainers)
Top GitHub Comments
Howdy @natterstefan - try this - Husky just put out a check for the
HUSKY_SKIP_HOOKS
variable (issue here)- this will skip all husky hooks, which I think gets the bahaviour you would like.package.json:
Please let me know how this works for you.
HUSKY_SKIP_HOOKS
no longer works (as of at least 6.0.0). TheHUSKY=0
variable should be now be used instead (see https://typicode.github.io/husky/#/?id=bypass-hooks).