Open MartinMuzatko opened 6 years ago
I suspect you might not have an adapter configured in your repo and thus git-cz is operating as if there is no package. This means that you should either pass it -m "My commit message" in order to avoid having your editor open or set a global adapter on your system. Just a guess.
Hello, I have the same issue (but on real Linux system :smiley:) I think it's the same problem in issue #558 You have to run
commitizen init cz-conventional-changelog --save-dev --save-exact
before to make your repo comittizen friendly
I think the readme should be updated to indicate the command to be executed for new projects as a commitizen beginner, it did not seem very clear to me :wink:
@sfauvart I agree that this could be more clear.
Faced the same issue. You can enforce this globally as mentioned within the README. Here's a one-liner fix:
$ npm install -g commitizen cz-conventional-changelog && echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
IMO, the readme needs an update to mention this "first". The current sequence creates this confusion:
And this little gem gets easily ignored:
If you're not working in a Commitizen friendly repository, then git cz will work just the same as git commit.
So if the readme can emphasise the repo needs to be commitizen friendly first (and if not, how to make it so), I think this confusion will go away.
I just had to explain the same to my colleague and I'm sure many others face the same problem.
@mrchief agreed! Would you be open to submitting a docs pr for the readme in a format that makes more sense to you given the scenario you described?
Sure! Although it may take me a while for me so if anyone else wants to pitch in, please feel free.
Following this guide, I solved this problem. I hope it can help you. https://medium.com/@lorenzen.jacob/standardize-git-commit-messages-b3f938f078be
Same issue, and I installed adapter. git cz --hook
opens editor whereas git-cz
does not:
This opens editor:
.czrc (local)
{ "path": "cz-conventional-changelog" }
.huskyrc
{
hooks: {
"prepare-commit-msg": "exec < /dev/tty && git cz --hook",
"pre-commit": "echo 'some message' && npm run doc && git add README.md && lint-staged",
"commit-msg": "commitlint -e $GIT_PARAMS"
}
}
If I delete prepare-commit-msg
hook and use git-cz
directly, no editor opens:
package.json
{
"scripts": {
"commit": "git-cz"
}
}
I want to have prepare-commit-msg
for those unaware of commitizen
in project.
Thanks,
@ozum did you find any solution? I don't like to run npm run x
for just git commit ... Integration with commit hook is the best.
@semoal unfortunately no.
:tada: This issue has been resolved in version 3.1.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Using 3.1.2, my issue still persists... Is it possible to reopen this case?
@ozum Is your repo commitizen friendly?
@mrchief, yes it is commitizen friendly, you can see my repo here to see configuration: https://github.com/ozum/scrap/tree/v0.0.37
I'm experimenting a few things for the workflow in that repo.
With "prepare-commit-msg": "exec < /dev/tty && git cz --hook"
;
git commit
, editor opens,npm run commit
, then commitizen prompts/questions executed more than once. (It asks again when I finished to answer questions)Note: In v.0.0.38, I disabled "prepare-commit-msg": "exec < /dev/tty && git cz --hook"
, then npm run commit
works as expected. Of course git commit
by-passes commitizen.
can i pass a adapter path in command , for example , git cz path-to-adapter ?
When I execute git commit, editor opens,
@ozum cz-cli doesn't hook into git commit
. So what you're seeing is normal.
@itninja-hue That seems like a separate question altogether. You should open up a new issue.
@achillesrasquinha thx
I also had trouble with the editor popping up when using the prepare-commit-msg
hook. git commit
would result in the editor popping up, but git commit -m '<any message>'
would work correctly. Adding this function to my .bashrc
seems to work because it overrides git commit
with git commit -m ''
.
function git {
if [[ "$1" == "commit" && "$@" != *"--help"* ]]; then
shift 1
command git commit -m ''
else
command git "$@"
fi
}
Lots of time passed, I returned to adjust my workflow.
Using `"prepare-commit-msg": "exec < /dev/tty && git cz --hook";
Is there a solution not to open local editor?
Still relevant for me, I have a commitzen-friendly repository and I want commitzen to be enforced for people unaware of it. Is there any way to achieve it?
Any update to this? I'm facing exactly the same issue as described above, tried various combinations and commands and it either runs twice, or opens vim at the end. Frustrating and makes the prompt part of commitzen useless for me
When I execute git commit, editor opens
!!! ref: https://github.com/commitizen/cz-cli/issues/934#issuecomment-1982811302
git config --local core.editor cat
git cz is broken for me.
I wanted to get started but it does not work.
I'm using Windows WSL (ubuntu shell on windows) together with zsh.
This is my gitconfig:
Even with my gitconfig removed, I get the following:
Is there a known bug?