1

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?

  • My git remote is setup:
origin  [email protected]:myuser/my_repo.git (fetch)
origin  [email protected]:myuser/my_repo.git (push)
  • Git branch shows:
 fix/my-new-branch
 * main
1
  • Run git log --all --decorate --oneline --graph (or see Pretty Git branch graphs for various alternatives) and see whether there should be commits in the origin/HEAD..HEAD range. If not, that's the problem; if so, there's something wrong with your pre-commit hook. (Note that it's possible that the lack of commits between origin/HEAD and HEAD itself is fine, and the expectation that there be some such commits is the problem with the pre-commit hook.) In any case this isn't Git, it's some add-on. Commented Dec 2, 2022 at 21:07

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.