Title: fix(check): expand env vars in rev_range arg by ilitygergo · Pull Request #1993 · commitizen-tools/commitizen · GitHub
Open Graph Title: fix(check): expand env vars in rev_range arg by ilitygergo · Pull Request #1993 · commitizen-tools/commitizen
X Title: fix(check): expand env vars in rev_range arg by ilitygergo · Pull Request #1993 · commitizen-tools/commitizen
Description: Description Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Code Changes Add test cases to all the changes you introduce Run uv run poe all locally to ensure this change passes linter check and tests Manually test the changes: Verify the feature/bug fix works as expected in real-world scenarios Test edge cases and error conditions Ensure backward compatibility is maintained Document any manual testing steps performed Update the documentation for the changes Documentation Changes Run uv run poe doc locally to ensure the documentation pages renders correctly Check and fix any broken links (internal or external) Expected Behavior The commitizen-branch pre-push hook should successfully validate commit messages using the ref range provided by pre-commit via the PRE_COMMIT_FROM_REF and PRE_COMMIT_TO_REF environment variables. Steps to Test This Pull Request Add the following to your .pre-commit-config.yaml: repos: - repo: https://github.com/commitizen-tools/commitizen rev: master hooks: - id: commitizen stages: [commit-msg] - id: commitizen-branch stages: [pre-push] Install the pre-commit hooks: pre-commit install --hook-type pre-commit --hook-type commit-msg --hook-type pre-push Make a commit with a valid conventional commit message: git commit -m "feat: my new feature" Run git push — the commitizen-branch hook should pass instead of failing with: fatal: ambiguous argument '$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF': unknown revision or path not in the working tree Environment used for testing: Python 3.14.3 commitizen 4.15.1 pre-commit 4.6.0 Additional Context The root cause is that pre-commit passes args directly to the process as a list without shell interpolation, so $PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF arrives as a literal string to cz check rather than being expanded to actual git SHAs. Pre-commit does set these as environment variables in the hook process, so os.path.expandvars() correctly resolves them at runtime. Closes #1923 Closes #1912 Related to #704
Open Graph Description: Description Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Code Changes Add test cases to all ...
X Description: Description Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Code Changes Add test cases to all ...
Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1993
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0e67f77e-fbc5-b66a-6624-aa0fae9fd572 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 83C4:322E35:1307926:19E0AF3:6A4EF698 |
| html-safe-nonce | 2c52541001a2876428afaa7b92b36fce29ec67b3a65de3f955101503eee57505 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0M0OjMyMkUzNToxMzA3OTI2OjE5RTBBRjM6NkE0RUY2OTgiLCJ2aXNpdG9yX2lkIjoiMzcxNTE4NTc4ODQzNjAxODg0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 63ba90523a07313730e5b26a997009e86d1c67c2e7dbdd2ca219a1eb3b446d02 |
| hovercard-subject-tag | pull_request:3681776483 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/commitizen-tools/commitizen/pull/1993/files |
| twitter:image | https://avatars.githubusercontent.com/u/33053717?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/33053717?s=400&v=4 |
| og:image:alt | Description Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Code Changes Add test cases to all ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width