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.

[Question] commitizen and standard-version together doesn't work (prepare-commit-msg hook can't be skipped)

See original GitHub issue

Hi,

I have the following issue, which was somehow discussed in the PR of the feature “feat(cli): Implement --hook option for git hooks integration”:

The Problem

When using the proposed hook solution together with husky, I am not able to skip the git hooks when using standard-version’s release command (see command here).

What I do

Basically, this is what I have and do (used in my react-component-catalog package):

// package.json
"scripts": {
    "release": "standard-version"
  },
"husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "prepare-commit-msg": "exec < /dev/tty && git cz --hook"
    }
  },

Whenever I release something, I execute one of these commands:

npm run release -- --no-verify
# or
npx standard-version --no-verify

This results in the following error:

image

What I expect and need

I want to be able to use commitizen together with standard-version when creating a new release.

How? Either it would be great to tell the git cz command to skip interactive mode or entirely for this specific task, or I should use another hook (which I have not yet tested though).

Whatever is better, I am happy if someone can assist me here. 👍

Hints, Links etc.

During my research I stumbled upon an issue raised in the husky package. He wanted to create “(…) a custom prepare-commit-msg hook that appends an ID to the commit msg.” and also had troubles skipping it.

He got a response containing the following hint:

commit-msg hook better suits your needs.

Because prepare-commit-msg does not allow --no-verify

prepare-commit-msg […] The purpose of the hook is to edit the message file in place, and it is not suppressed by the --no-verify option.

commit-msg […] can be bypassed with the --no-verify option. […] It can also be used to refuse the commit after inspecting the message file.

https://git-scm.com/docs/githooks#_prepare_commit_msg

Does that mean I should use commit-msg instead to make this work? But then people are not enforced anymore to use commitizen…

Thank you for your help!

Issue Analytics

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

github_iconTop GitHub Comments

26reactions
olgncommented, Jul 3, 2019

Howdy @natterstefan - try this - Husky just put out a check for the HUSKY_SKIP_HOOKS variable (issue here)- this will skip all husky hooks, which I think gets the bahaviour you would like.

package.json:

{
  ...
  "scripts": {
    ....
    "release": "HUSKY_SKIP_HOOKS=1 standard-version",
    ...
  }
}

Please let me know how this works for you.

10reactions
rickstaacommented, Sep 9, 2021

HUSKY_SKIP_HOOKS no longer works (as of at least 6.0.0). The HUSKY=0 variable should be now be used instead (see https://typicode.github.io/husky/#/?id=bypass-hooks).

Read more comments on GitHub >

github_iconTop Results From Across the Web

lint-staged + commitizen configuration suitable for command ...
I just came across this issue myself. The issue can be resolved quite easily, just add a short-circuit when TTY fails
Read more >
Automatically generate and release a changelog using Node.js
In this tutorial, we'll explore a method for automatically generating and releasing a changelog that uses git hooks and Node.js. We'll create a ......
Read more >
Set up ESLint, Prettier, Commitizen, Husky and friends in 2022
Husky is a great tool for configuring git hooks, which can automatically lint code and commit messages, run unit tests (and so much...
Read more >
Semantic release with commitizen and commitlint | mdluo's blog
This post will demonstrate a conventional local setup and CI steps. Install husky for git hooks management. npm install --save-dev husky.
Read more >
CZ-cli: The Commitizen Command Line Utility - Morioh
If you're not working in a Commitizen-friendly repository, then git cz will work just the ... Update .git/hooks/prepare-commit-msg with the following code:
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