-
Notifications
You must be signed in to change notification settings - Fork 552
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
Run pre-commit hook before the prompt #604
Comments
Yes please, I've run into that a ton of times as well 😁 |
Then, I'll take a crack tonight. |
After taking a look at this I found the While this is almost what I want, if I use |
Personally agree, would like to know what @jimthedev thinks though |
Definitely an issue... if |
Yes, I agreed and this's been an issue for my team as well. One naive solution I can think of is that
https://github.com/commitizen/cz-cli/blob/master/src/commitizen/commit.js#L47-L62 |
At this point I think it's pretty clear there is community support and I don't think |
@dkimot what do you mean? After fixing the formatting do you mean that the changes should get automatically staged? I'd recommend not doing that, you don't want any magic concerning what is staged and what isn't:
|
I've managed to resolve this issue somehow, a bit hacky IMO, but it seems to be working fine. I got rid of husky's pre-commit hook and moved script it was executing to the npm scripts section. "scripts": {
"pre-commit": "yarn lint:ignore-tests && yarn test && lint-staged && git add --all",
"cmz": "npm run pre-commit && git-cz"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"config": {
"commitizen": {
"path": "git-cz"
}
} After But, I still seem to have an issue when running git commit instead of |
We shouldn't allow the the cli to run if pre-commit hook fails and also if files are not added. Did everyone agree on this ? Is anyone working on this ? Or Can I take this up ? |
Take it up! Take it up! 😬 |
@ad1992 && @brandondurham - Any updates on your fixes so that the pre-commit hook will run before |
Any updates here? My team just started using commitizen and love it, but having specs or linting run first would be great |
Any updates here ? I'm using git cz and have the same question - how to crash cli if pre-commit hook was failed. |
I use a similar approach as what @Puritanic mentioned above, and it doesn't need changes to the cli
I feel this is much simpler as I do not have to remember that I have to run an npm script just to do a git commit, but it would be good if the cli takes care of running the |
Any update on this? It's been almost 2 years |
@Puritanic You can keep husky by adding |
Would it not work to temporarily set the git |
Have we got any updates on this? It's been 4 years already. Just started to use commitizen and having this issue fixed would be great. |
I use pre-commit hooks to format my code and check with
npm audit
for insecure modules. There are times I run through the whole commit prompt only to have my pre-commit hook(s) fail and have to redo my commit message.I think it would be great if the cli ran pre-commit hooks before the prompt much like it checks that some files have been added to staging.
I'm happy to work on a PR, just curious what the community thinks.
The text was updated successfully, but these errors were encountered: