Skip to content

pre-commit hook for commitizen-branch broken since 4.15.1 #2003

Description

@Thomas-Neumann

Description

I can't upgrade my pre-commit hooks from 4.15.0 to 4.15.1 since it would break commitizen-branch.

The error message is:

commitizen check branch..................................................Failed
- hook id: commitizen-branch
- exit code: 23

fatal: ambiguous argument '$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
default_install_hook_types:
  - pre-commit
  - pre-push

repos:
  - repo: https://github.com/commitizen-tools/commitizen
    rev: v4.15.0
    hooks:
      - id: commitizen-branch
        stages:
          - pre-push
          - 

Steps to reproduce

  1. Create branch and make a dummy change
  2. Use above configuration
    1. git add && git commit (works)
    2. git push (works)
  3. Create a new commit, update to any newer version (4.15.1 / 4.16.0 / 4.16.1 / 4.16.2)
    1. git add && git commit (works)
    2. git push (fails)

Current behavior

Any version newer than 4.15.0 fails with an error.

Configuration:

repos:
  - repo: https://github.com/commitizen-tools/commitizen
    # can be any of: 4.15.1, 4.16.0, 4.16.1, 4.16.2
    rev: v4.15.1
    hooks:
      - id: commitizen-branch
        stages:
          - pre-push

Error:

commitizen check branch..................................................Failed
- hook id: commitizen-branch
- exit code: 23

fatal: ambiguous argument '$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Desired behavior

I can update commitizen-branch to use the most recent version (4.16.2).

Screenshots

Image

Environment

No output for cz version --report since I don't have cz installed.
Commitizen is managed by the pre-commit hook.

pre-commit version in case it's relevant: 4.6.0

Activity

  1. j178 commented on May 29, 2026

    @j178

    I think this was introduced by #1941. Commitizen no longer runs the Git command through shell=True, so the environment variable placeholders in the rev range are not expanded by a shell anymore.

  2. bearomorphism commented on May 30, 2026

    @bearomorphism
    Collaborator

    @j178 Thanks for your RCA. Let me take a look.

  3. bearomorphism commented on May 30, 2026

    @bearomorphism
    Collaborator

    Opened #2005 with the fix and a regression test that reproduces the exact atal: ambiguous argument error from this issue when the fix is reverted. Thanks again @j178 for the root-cause analysis.

  4. added a commit that references this issue on May 30, 2026
    8f5b496
  5. Thomas-Neumann commented on Jun 1, 2026

    @Thomas-Neumann
    Author

    Thank you so much for fixing this bug.
    I can confirm that 4.16.3 fixes the reported issue.

  6. bearomorphism commented on Jun 2, 2026

    @bearomorphism
    Collaborator

    Thank you!

  7. stelewis commented on Jun 7, 2026

    @stelewis

    Thanks for fixing this! Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions