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

commitizen produces empty commit message after answering prompts #967

Open
gee4vee opened this issue Feb 13, 2023 · 3 comments
Open

commitizen produces empty commit message after answering prompts #967

gee4vee opened this issue Feb 13, 2023 · 3 comments

Comments

@gee4vee
Copy link

gee4vee commented Feb 13, 2023

Description

We set up cz as a husky pre-commit hook but when we go through the prompts via git commit it produces an empty commit message in vim.

These commands were executed to set it up:

npm install --save-dev commitizen
npx commitizen init cz-conventional-changelog --save-dev --save-exact
npx husky-init && npm install 

Our .husky/prepare-commit-msg:

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo '[husky] Running commitizen for prepare-commit-msg hook...'
exec < /dev/tty && npx cz --hook || true

Steps to reproduce

  1. Execute git commit.
  2. Answer the cz prompts.
  3. A vim editor is opened.

Current behavior

The vim editor has an empty commit message and commitizen errors out due to an empty commit message.

Desired behavior

commitizen produces a commit message using information entered in prompts.

Screenshots

git commit
[husky] Running commitizen for prepare-commit-msg hook...
[email protected], [email protected]

All lines except first will be wrapped after 100 characters.
? Select the type of change that you're committing: chore:    Changes that don't modify src or test files
?
Denote the SCOPE of this change (optional): empty
? Write a SHORT, IMPERATIVE description of the change:
 cz message prompt tweak
? Provide a LONGER description of the change (optional). Use "|" to break new line:
 false
? List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:

str.match is not a function
Aborting commit due to empty commit message.

image

Environment

[email protected]
[email protected]

@Zhengqbbb
Copy link
Contributor

Only use alias

  1. use npm script and run npm cz like:
{
  "cz": "git commit -m ''"
}
  1. Add ~/.bashrc or ~/.zshrc alias fn
git() {
  local _cmd="$*"
  if [ "$1" = "commit" ] && [ "${_cmd%%"--help"}" = "$_cmd"  ]; then
    shift 1; command git commit -m ''
  else
    command git "$@"
  fi
}

ISSUE Thread:
Zhengqbbb/cz-git#87

@sanjorcool
Copy link

@gee4vee Has this issue been resolved? I have the same problem and very confused, what is the cause of this problem

@sanjorcool
Copy link

@gee4vee Hi, you can try to upgrade your git to the latest version. My problem has been solved by upgrading git. The cause of the problem should be that the hook of git commit bash is not compatible with commitizen and husky.

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