fix(check): expand env vars in rev_range arg#1993
Open
ilitygergo wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1993 +/- ##
=======================================
Coverage 98.23% 98.23%
=======================================
Files 61 61
Lines 2779 2782 +3
=======================================
+ Hits 2730 2733 +3
Misses 49 49 ☔ View full report in Codecov by Sentry. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Checklist
Was generative AI tooling used to co-author this PR?
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsDocumentation Changes
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
The
commitizen-branchpre-push hook should successfully validate commit messagesusing the ref range provided by pre-commit via the
PRE_COMMIT_FROM_REFandPRE_COMMIT_TO_REFenvironment variables.Steps to Test This Pull Request
.pre-commit-config.yaml:pre-commit install --hook-type pre-commit --hook-type commit-msg --hook-type pre-pushgit commit -m "feat: my new feature"git push— thecommitizen-branchhook 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 treeEnvironment used for testing:
Additional Context
The root cause is that pre-commit passes
argsdirectly to the process as a listwithout shell interpolation, so
$PRE_COMMIT_FROM_REF..$PRE_COMMIT_TO_REFarrivesas a literal string to
cz checkrather 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