-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Added prepare-commit-msg hook to check commit prefixes. #20381
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
base: main
Are you sure you want to change the base?
Conversation
| # Cherry-pick the commit, but skip hooks | ||
| git -c core.hooksPath=/dev/null cherry-pick ${REV} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://adamj.eu/tech/2023/02/13/git-skip-hooks/#skip-unskippable-hooks-with-core-hookspath
The hooks will run below, when git commit --amend is run.
| # Install this prepare-commit-msg hook with | ||
| # pre-commit install --hook-type prepare-commit-msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the install step.
| # Cherry-pick the commit | ||
| git cherry-pick ${REV} | ||
| # Cherry-pick the commit, but skip hooks | ||
| git -c core.hooksPath=/dev/null cherry-pick ${REV} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It occurs to me this isn't windows-friendly, but we can cross that bridge later. Perhaps we would want to just replace the backport script entirely with a fleshed out prepare-commit-msg hook.
I confess to running `git cherry-pick` accidentally a few times instead of the backport script, resulting in missing branch prefixes.
9dd4663 to
410445f
Compare
|
|
||
| # Cherry-pick the commit | ||
| git cherry-pick ${REV} | ||
| # Cherry-pick the commit, but skip hooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shows what we want -- I normally want the hook to catch naive uses of git cherry-pick, so I have to skip the hook here (where a naive cherry-pick is done intentionally).
I confess to running
git cherry-pickaccidentally a few times instead of the backport script, resulting in missing branch prefixes.This should be invisible for most contributors, as
pre-commit installdoes not installprepare-commit-msghooks by default, see the installation command at the top of the script.