Created
April 16, 2019 14:46
-
-
Save LukasForst/39310e80bbbc0ea5dd5525564987446b to your computer and use it in GitHub Desktop.
Add Jira task number to your commit message
This file contains 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
# Add git branch if relevant | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
# Extact tracker abbreviation and ticket number (e.g. DS-123) | |
parse_git_tracker_and_ticket() { | |
parse_git_branch | grep -e '[A-Z]\+-[0-9]\+' -o | |
} | |
MESSAGE="$(cat $1)" | |
TICKET=`parse_git_tracker_and_ticket` | |
if [ -n "$TICKET" ] | |
then | |
echo "New commit message: [$TICKET] $MESSAGE" | |
echo "$TICKET - $MESSAGE" > $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this into
.git/hooks/
folder