Last active
July 9, 2019 15:30
-
-
Save kunicmarko20/1f0ce2ad6ca37854e5fdea8071556b70 to your computer and use it in GitHub Desktop.
Prefix commit with ticket number from the branch if it isn't already prefixed
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
#./.git/hooks/prepare-commit-msg | |
COMMIT_PREFIX=$(git symbolic-ref --short HEAD | grep -Po 'PROJECT-([0-9]+)'); | |
HAS_TICKET_NUMBER=$(grep -Po 'PROJECT-([0-9]+)' $1); | |
if [ -n "$HAS_TICKET_NUMBER" ]; then | |
return; | |
fi | |
if [ -n "$COMMIT_PREFIX" ]; then | |
sed -i.bak -e "1s/^/[$COMMIT_PREFIX] /" $1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment