question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

husky falls back to original git commit message prompt if I cancel when displaying commitizen prompt

See original GitHub issue

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:

  "husky": {
    "hooks": {
      "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true"
    }
  },

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
jaikmecommented, Jan 25, 2021

For me, I’m trying to use the single command git commit and 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-cz

But 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_EDITMSG or is the default behavior?

0reactions
Dunky13commented, Jan 28, 2022

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"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Commitlint, Commitizen, Standard ... - DEV Community ‍ ‍
First, install commitlint , a linting tool to check if your commit messages meet the conventional commit format:.
Read more >
Add Commitlint, Commitizen, Standard Version, and Husky to ...
You can find the demo repo here: conventional-commits-sveltekit. commitlint. First, install commitlint , a linting tool to check if your commit messages meet ......
Read more >
@commitlint/prompt | Yarn - Package Manager
This is the library and commitizen adapter version of commitlint prompt. A ready-to-use cli version is available at @commitlint/prompt-cli.
Read more >
How do I stop a Git commit when VI is on the screen waiting ...
You have two options: Provide an empty commit message. If it's a new commit and you haven't yet saved the message, you can...
Read more >
Add Commitlint, Commitizen, Standard Version, and Husky to ...
Now let's test if commitlint works (no prompt if linting passed): ... to check your commit message before making any git commit ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found