Repository navigation
husky falls back to original git commit message prompt if I cancel when displaying commitizen prompt #688
Description
Activity
Having the same issue - it looks like git-cz returns a 0 exit code even when CTRL-C'd. Not sure why commitizen traps the SIGINT but it should probably be surfaced. If it returns a non-zero exit code it should work with husky and prevent the standard git message from showing.
i am having the same issue.
commitizen using Inquirer.js for prompt.
Inquirer.js trapsSIGINT, and It have not any exit handlers.
I found implementation workarounds in their discussion, and related issue thatSIGINTtrap not work normally.It might be a
Inquirer.js's issue.
but the workaround looks like work enough.process.stdin.on("data", (key) => { if (key == "\u0003") { process.exit(1); } });
add above to
bin/git-cz.js, CTRL-C will work withInquire.js's hooks.🎉 This issue has been resolved in version 4.2.2 🎉
The release is available on:
Your semantic-release bot 📦🚀
For me, I'm trying to use the single command
git commitand it prompt to choose my type:husky > pre-commit (node v12.17.0) ℹ No staged files match any configured task. husky > prepare-commit-msg (node v12.17.0) ? Select the type of change that you're committing: (Use arrow keys or type to search) ❯ test: Adding missing tests feat: A new feature fix: A bug fix chore: Build process or auxiliary tool changes docs: Documentation only changes refactor: A code change that neither fixes a bug or adds a feature style: Markup, white-space, formatting, missing semi-colons...Then I make de description:
... ? Select the type of change that you're committing: chore: Build process or auxiliary tool changes ? Write a short, imperative mood description of the change: [-------------------------------------------------------------] 34 chars left chore: husky hook on git-czBut it's falling back to VIM to edit COMMIT_EDITMSG:
chore: husky hook on git-cz ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "~/repo/.git/COMMIT_EDITMSG" [noeol] 1L, 27C
My pakcage.json husky config and version:
... "dependencies": { "@commitlint/cli": "^11.0.0", "@commitlint/config-conventional": "^11.0.0", "@commitlint/config-lerna-scopes": "^11.0.0", "commitizen": "^4.2.3", "cz-conventional-changelog": "^3.3.0", "eslint": ">=6.0.0", "git-cz": "^4.7.6", "husky": "^4.3.8", "lerna": "^3.22.1", "lint-staged": "^10.5.3", "prettier": "^2.2.1", "stylelint": "^13.9.0" }, "husky": { "hooks": { "pre-commit": "lint-staged", "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true", "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } },-> Some can help me with this issue? There is some "thing" to avoid open the
COMMIT_EDITMSGor is the default behavior?Reacted by Gabriel Minossi and Mariano NtrougkasReacted by Keit Ollé, Luan Castheloge, Jaemin Cheun, Alex Thompson, Jacy Anderson, Philip Carneiro, Juan Calle, Supasai, Max Kuzmenko, k2on and 9 moreHas there been any fix to this?
I am on 4.2.4 but I still have the same issue. If I hitCtrl+Cwhile answering all the questions, it falls back to vim and then that commit message is used.Having this issue as well, sadly throws me to vim commit message if I use
CTRL+C"commitizen": "^4.2.4", "git-cz": "^4.8.0", "husky": "^7.0.4"
So, this has been closed without actually being fixed 🤔 😞
Hello.
I am using Husky together with Commitizen to execute git-cz when doing a git commit.
I have defined the following configuration as stated in the documentation:
Everything works fine and I am prompted to choose the commit message from commitizen.
The problem is if I hit CTRL-C to cancel my commit, it just closes the commitizen prompt and falls back to the original git commit prompt. I want to abort everything in this case and dont do the commit.
I have tried to remove the "|| true" from the prepare-commit-msg command but it´s the same.
Not sure if it´s an issue of husky or commitizen.
Thanks for the help.