commitizen / cz-cli

The commitizen command line utility. #BlackLivesMatter
http://commitizen.github.io/cz-cli/
MIT License
16.58k stars 552 forks source link

cz opens editor after CLI successfully build commit message #907

Closed rafae2k closed 2 years ago

rafae2k commented 2 years ago

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.

gomesdigital commented 2 years ago

I'm having the same experience as @rafae2k. Seems to be a known issue already though. See #839 from '21.

Zhengqbbb commented 2 years ago

If you add this hook, you should use git commit to start it

BTW: This is not recommended to add this hook

rafae2k commented 2 years ago

@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...)

Zhengqbbb commented 2 years ago

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

Zhengqbbb commented 3 months ago

ref: https://github.com/commitizen/cz-cli/issues/934#issuecomment-1982811302

git config --local core.editor cat

image