Title: fix(check): expand env vars in --rev-range by bearomorphism · Pull Request #2005 · commitizen-tools/commitizen · GitHub
Open Graph Title: fix(check): expand env vars in --rev-range by bearomorphism · Pull Request #2005 · commitizen-tools/commitizen
X Title: fix(check): expand env vars in --rev-range by bearomorphism · Pull Request #2005 · commitizen-tools/commitizen
Description: Description Fix regression where the packaged commitizen-branch pre-push hook stopped working after v4.15.0. The hook passes the literal .. as a single argv element. Before #1941 the surrounding shell=True expanded the env vars; after #1941 (CWE-78 hardening) git receives the literal string and aborts with fatal: ambiguous argument. Fix: expand env vars on the --rev-range argument via os.path.expandvars in Check.__init__. Unset vars are left literal so git can surface a clear error rather than silently rewriting the range to empty. Closes #2003. Credit to @j178 for the root-cause analysis. Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Generated-by: GitHub Copilot CLI following the guidelines 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 Update the documentation for the changes (N/A -- no user-facing CLI change) Expected Behavior cz check --rev-range "$VAR1..$VAR2" resolves env vars before invoking git log, matching the pre-#1941 contract that the packaged hook relied on. Steps to Test This Pull Request git init repro && cd repro git commit --allow-empty -m "feat: first" git commit --allow-empty -m "fix: second" export PRE_COMMIT_FROM_REF=$(git rev-parse HEAD~1) export PRE_COMMIT_TO_REF=$(git rev-parse HEAD) cz check --rev-range "$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REF" Before: fatal: ambiguous argument (exit 23). After: Commit validation: successful!. New automated coverage in tests/commands/test_check_command.py: two unit tests plus test_check_rev_range_pre_commit_branch_hook_regression -- an E2E test against a real git repo that reproduces the exact issue error when the fix is reverted.
Open Graph Description: Description Fix regression where the packaged commitizen-branch pre-push hook stopped working after v4.15.0. The hook passes the literal .. as a single argv element. Before #1941 the surrounding sh...
X Description: Description Fix regression where the packaged commitizen-branch pre-push hook stopped working after v4.15.0. The hook passes the literal .. as a single argv element. Before #1941 the surrounding sh...
Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/2005
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:0480c732-dc5a-65f3-8789-361e2717244f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DDB8:3ED847:CD4397:12EBCB5:6A4E2A45 |
| html-safe-nonce | 08bd25e71da715848cc009993e0dc9d327571b2864247756e04a43fe0e94123c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEREI4OjNFRDg0NzpDRDQzOTc6MTJFQkNCNTo2QTRFMkE0NSIsInZpc2l0b3JfaWQiOiI4MjU3MjY2MzIxMzIzODYyNTk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fff5d244014c28ab1e7ebe362d38f0207d56609493fe85621ae1e0cb0c7dff25 |
| hovercard-subject-tag | pull_request:3772834665 |
| 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/2005/files |
| twitter:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| og:image:alt | Description Fix regression where the packaged commitizen-branch pre-push hook stopped working after v4.15.0. The hook passes the literal .. as a single argv element. Before #1941 the surrounding sh... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| 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 | d9dd20d38f8ae3c4cb6b597807431db300d0bd2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width