cz opens editor after CLI successfully build commit message
rafae2k opened this issue · comments
I'm using husky, commitzen and commitlint to setup my commit messages.
i added a prepare-commit-msg hook on husky to create my commit using commitzen cli. It all works perfectly, but when i finish my message on cli it opens the editor, and only when i close the editor it successfully create my commit.
If you add this hook, you should use git commit
to start it
BTW: This is not recommended to add this hook
- Because it will change the original behavior of git commit, so that will lose fast commit methods such as git commit -m "xxx"
- And it will eventually open vi so that will lose the convenience of using the CLI
@Zhengqbbb i have all hooks, following git workflow.
pre-commit
- runs lintstaged
prepare-commit-msg
- runs cz
commit-msg
- runs commitlint
even though with or without commit-msg when prepare-commit-msg
it opens editor (vim, code, etc...)
prepare-commit-msg - runs cz
Let's see why
The first is the name of the hook, think about what it means: prepare-commit-msg
.
And then is the hook behavior, why does the editor open. You can try running the command git commit
in other projects without hooks.
Anyway, this hook is triggered once the commit message is added, and the hook running the command will eventually become git commit
, and it will automatically open the editor to edit your .git/COMMIT_EDITMSG
file.
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks search text: prepare-commit-msg
BTW As a CLI shouldn't use that hook for launching, I think it's wrong
https://cz-git.qbenben.com/cli/install.html#as-git-hooks-use