You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
commitizen-branch fails with exit code: 23 and message fatal: ..: '..' is outside repository #1923
Added explicit environment variable expansion in cz check --rev-range.
This restored handling of:
$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF
without using shell expansion.
Additional detail:
Expansion of both variables was added here.
Expansion of a single variable can be observed after this change when only one environment variable is available, for example: $PRE_COMMIT_FROM_REF..00c7da778d77ffdd2e380415e3fd47bab286bc88
Of course these PRs are linked, but i tested commits with this script which accepts a ref for commitizen to test the hook behaviour for a given tag or commit.
Activity
natelandau commentedon May 8, 2026
I ran in to the same problem, I think this hook depends on an args-substitution behavior that doesn't work in all pre-commit runners (I use Prek).
As a workaround, I wrote my own local hook to get the expected behavior:
mcsitter commentedon Jul 28, 2026
Some of my findings.
Running against
master,commitizen-branchfails with bothprekandpre-commit, but differently.With
prek,PRE_COMMIT_TO_REFis expanded whilePRE_COMMIT_FROM_REFremains literal ($PRE_COMMIT_FROM_REF..<sha>).With
pre-commit, both variables remain literal ($PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF).Here is more info regarding the changes to the variables.
The relevant changes were introduced in these pull requests:
commitizen-branchhook arguments changed to use pre-commit variablesPR: #1815
Changed:
args: [--rev-range, origin/HEAD..HEAD]to:
args: [--rev-range, "$PRE_COMMIT_TO_REF $PRE_COMMIT_FROM_REF"]This introduced the use of
PRE_COMMIT_FROM_REF/PRE_COMMIT_TO_REFin the packaged hook configuration.commitizen-branchrev-range syntax changedPR: #1841
Changed:
args: [--rev-range, "$PRE_COMMIT_TO_REF $PRE_COMMIT_FROM_REF"]to:
args: [--rev-range, "$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF"]This changed the hook argument from two space-separated refs to the Git range syntax.
PR: #1941
This changed Git command execution from shell-based execution to
shell=False.After this change, the literal argument:
$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REFwas passed directly to Git instead of being expanded by the shell.
The failure changed from:
- exit code: 3to:
- exit code: 23with:
fatal: ambiguous argument '$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF': unknown revision or path not in the working tree.--rev-rangePR: #2005
Added explicit environment variable expansion in
cz check --rev-range.This restored handling of:
$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REFwithout using shell expansion.
Additional detail:
$PRE_COMMIT_FROM_REF..00c7da778d77ffdd2e380415e3fd47bab286bc88Of course these PRs are linked, but i tested commits with this script which accepts a ref for commitizen to test the hook behaviour for a given tag or commit.
Hope this helps!