Last active
December 23, 2015 00:42
-
-
Save Thann/04544bbff94254a7b543 to your computer and use it in GitHub Desktop.
GIT: Prepend the Jira ticket from the branch name to the 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
#!/bin/sh | |
# | |
# Prepend the Jira ticket from the branch name to the commit message | |
# Do nothing when amending or fixing | |
if [ -n "$2" ]; then exit 0; fi | |
BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
TICKET_NAME=$(echo $BRANCH_NAME | grep -Eo "^\w{2}[-_][0-9]+" | awk '{print toupper($0)}') | |
if [ -n "$TICKET_NAME" ]; then | |
sed -i.bak -e "1s/^/$TICKET_NAME - /" $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment