Created
December 16, 2019 21:42
-
-
Save abuduba/9af4e0594b061b48d3cb4385bf7583a8 to your computer and use it in GitHub Desktop.
Prepend ticket number in the commit message
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
#!/bin/bash | |
FILE=$1 | |
MESSAGE=$(cat $FILE) | |
TICKET=$(git rev-parse --abbrev-ref HEAD | sed -E 's/([a-z]+\/)?([a-z]+-[0-9]+).*/[\2]/' | tr "[:lower:]" "[:upper:]" | grep -Eo '^\[([A-Z]+-)?\d+/]$') | |
if [[ "$MESSAGE" == "$TICKET"* ]];then | |
exit 0; | |
fi | |
echo "$TICKET $MESSAGE" > $FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment