-
-
Notifications
You must be signed in to change notification settings - Fork 314
fix(pre-commit-hooks): remove magic constants on pre-push hook #1815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(pre-commit-hooks): remove magic constants on pre-push hook #1815
Conversation
- Remove static reference to origin (work with other name) - now work when remote/HEAD isn't setted (e.g. on `git init .; git remote add origin git@...`)
|
Interesting. I didn't know these variables. Additional details for |
|
Nice catch, thanks! |
|
After this change, invalid commit messages on |
Could you please create an issue and let us know how we can reproduce it? Thanks! |
|
Ok, I made a minumum reproducing repository: https://github.com/KyleMylonakisProtopia/commitizen-pr-1815-bug git clone git@github.com:KyleMylonakisProtopia/commitizen-pr-1815-bug.git
cd commitizen-pr-1815-bug
uv venv .venv
source .venv/bin/activate
uv pip install -e .
pre-commit install
git checkout -b new_branch
touch new_file
git add new_file
git commit -m "feat: add new file"
git pushFor me this fails with the error: (.venv) ➜ commitizen-pr-1815-bug git:(new_branch) git push --set-upstream origin new_branch
commitizen check branch..................................................Failed
- hook id: commitizen-branch
- exit code: 14
commit validation: failed!
please enter a commit message in the commitizen format.
commit "2bbee8154e795c7d9f77fd9e190d6d7bf5b9f325": "improperly formatted commit that introduced
"pattern: (?s)(build|bump|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\S+\))?!?: ([^\n\r]+)((\n\n.*)|(\s*))?$
commit "3d9318b341828644f23ff772a6f276be47bf825e": "first commit
"pattern: (?s)(build|bump|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\S+\))?!?: ([^\n\r]+)((\n\n.*)|(\s*))?$
error: failed to push some refs to 'github.com:KyleMylonakisProtopia/commitizen-pr-1815-bug.git' |
|
See #1818 |
Description
git init .; git remote add origin git@...)Checklist
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
git init)origin) isn't hard coded (or isn't to set in configuration file)Steps to Test This Pull Request
git init test-repocz initpre-commit install --hook-type commit-msg --hook-type pre-pushgit init && git add . && git commit -m "feat: well formed commit message"git remote add github_origin https://github.com/<some repo>.gitgit push -u github_origin mainAdditional Context
pre-commit autoupdateincluding if commitizen isn't updated (when new release published)FIX #704