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

cz opens editor after CLI successfully build commit message #907

Closed
rafae2k opened this issue Feb 23, 2022 · 5 comments
Closed

cz opens editor after CLI successfully build commit message #907

rafae2k opened this issue Feb 23, 2022 · 5 comments

Comments

@rafae2k
Copy link

rafae2k commented Feb 23, 2022

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
Copy link

gomesdigital commented Feb 24, 2022

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

@Zhengqbbb
Copy link
Contributor

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

@rafae2k
Copy link
Author

rafae2k commented Jun 25, 2022

@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
Copy link
Contributor

Zhengqbbb commented Jun 25, 2022

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

@rafae2k rafae2k closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2022
@Zhengqbbb
Copy link
Contributor

ref: #934 (comment)

git config --local core.editor cat

image

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

No branches or pull requests

3 participants