Reputation: 2907
I've recently started using commitizen in my day-to-day development, however I don't understand why I get the following error with the first commit to a new branch, ie:
...on current main branch...
git checkout -b fix/my-new-branch
...make some changes...
git commit -am "fix: did the thing"
commitizen check.........................................................Passed
commitizen check branch..................................................Failed
- hook id: commitizen-branch
- exit code: 3
No commit found with range: 'origin/HEAD..HEAD'
My pre-commit file looks like this:
---
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.37.1
hooks:
- id: commitizen
- id: commitizen-branch
stages: [commit-msg]
Is there something I'm missing here?
origin [email protected]:myuser/my_repo.git (fetch)
origin [email protected]:myuser/my_repo.git (push)
fix/my-new-branch
* main
Upvotes: 1
Views: 1091
Reputation: 70117
the commitizen-branch
hook is intended for after-the-fact usage and not during the commit-msg
stage -- you probably don't need it / don't want it and can have it removed
notably, the stages: [commit-msg]
is incorrect to set for that hook since it is not designed to run during commit-msg
(where no commits exist between origin/HEAD
and HEAD
)
personally I'd probably set that ones as stages: [manual]
such that it never automatically runs, but can be run on demand
disclaimer: I wrote pre-commit
Upvotes: 1