Skip to content

prek pre-push compatibility with Commitizen commitizen-branch #2133

Description

@stelewis

Summary

Summary

prek does not appear to expand the PRE_COMMIT_FROM_REF / PRE_COMMIT_TO_REF placeholders used by the upstream Commitizen commitizen-branch hook.

That hook currently defines:

- id: commitizen-branch
  entry: cz check
  args: [--rev-range, "$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF"]
  always_run: true
  pass_filenames: false
  stages: [pre-push]

Under pre-commit, this hook works as intended. Under prek, the placeholders appear to be passed through literally.

Versions

  • prek 0.4.3
  • commitizen 4.16.2
  • macOS
  • Git repo with pre-push hook installed via prek install

Reproduction

Use this .pre-commit-config.yaml snippet:

default_install_hook_types: [pre-commit, commit-msg, pre-push]

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

Then run either a real push or:

prek run --hook-stage pre-push commitizen-branch -v

Actual result

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.

Expected result

prek should provide compatibility with hooks that rely on the PRE_COMMIT_FROM_REF and PRE_COMMIT_TO_REF values during pre-push, so the hook receives a real revision range instead of the literal placeholder string.

Notes

  • prek docs mention pre-push environment variables, so this looks like a compatibility gap rather than a Commitizen-specific misconfiguration.

Willing to submit a PR?

  • Yes — I’m willing to open a PR to fix this.

Platform

MacOS Darwin 25.5.0 x86_64

Version

prek 0.4.3 (02bb73f 2026-05-27)

.pre-commit-config.yaml

- id: commitizen-branch
  entry: cz check
  args: [--rev-range, "$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF"]
  always_run: true
  pass_filenames: false
  stages: [pre-push]

Log file


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions