Open asjadanis opened 3 years ago
Hey @asjadanis, I'm kinda having the same issue, have you found a workaround for this?
I have the same problem i didn't find how to solve. Event if 'im not using husky and having a classic hook the command is run twice
@asjadanis did you find any solution to this?
same issue, runs twice using regular git hook or husky
This may or may not help people here, but we only run commitizen when no commit message is provided.
This means commitizen will not run with git commit -m
, nor with git commit --amend
, or for git merge commits etc... See https://git-scm.com/docs/githooks#_prepare_commit_msg for a full list of values the second arg can have.
# Only run commitizen if no commit message was already provided.
if [ -z "${2-}" ]; then
export CZ_TYPE="${CZ_TYPE:-fix}"
export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH
export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH
# By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen.
exec < /dev/tty && "$(dirname "$0")/git-cz.js" --hook
fi
Not sure if this is the problem people here are facing, but it might help someone.
This may or may not help people here, but we only run commitizen when no commit message is provided.
This means commitizen will not run with
git commit -m
, nor withgit commit --amend
, or for git merge commits etc... See https://git-scm.com/docs/githooks#_prepare_commit_msg for a full list of values the second arg can have.# Only run commitizen if no commit message was already provided. if [ -z "${2-}" ]; then export CZ_TYPE="${CZ_TYPE:-fix}" export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH # By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen. exec < /dev/tty && "$(dirname "$0")/git-cz.js" --hook fi
Not sure if this is the problem people here are facing, but it might help someone.
Thanks @techmunk. You are a life saver
this worked for me to make them both work at the same time:
prepare-commit-msg
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
if [ $2 == "template" ]; then
exec < /dev/tty && npx cz --hook || true
fi
Hi @roman-supy-io ,
Just curious if you mind clarifying how you achieved this? Where is "template"
coming from in the CLI? Is it something like git commit -m "template"
or is it a flag? Like git commit --template
?
Hi @roman-supy-io ,
Just curious if you mind clarifying how you achieved this? Where is
"template"
coming from in the CLI? Is it something likegit commit -m "template"
or is it a flag? Likegit commit --template
?
$2 is template
when run git commit
not like git commit -m
watching this
@techmunk cz is running when I pass a commit message.
ref: https://github.com/commitizen/cz-cli/issues/934#issuecomment-1982811302
git config --local core.editor cat
ref: #934 (comment)
git config --local core.editor cat
So what would happen when someone tries to run something like git rebase -i
? I don't think setting the default editor to cat is a sensible approach to resolving this issue.
I am trying to configure husky hooks with commitizen and lint-staged. This seems to trigger commit twice when I run
yarn cz
but when I run git commit it runs just once as expected. I have added githooks under the.husky folder
and the configuration can be seen below. I have already seen the issue mentioned on readme and renamed my script to cz but it doesn't seem to be running as expected.pre-commit
prepare-commit-msg