Last active
July 13, 2016 14:26
-
-
Save TheHippo/8ad10014b39f6210bae8c8decacb2620 to your computer and use it in GitHub Desktop.
If your git branch starts with a number add `ref #ISSUE-NUMBER` to commit msg
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/bash | |
NAME=$(git branch | grep '*' | sed 's/* //') | |
ISSUE_NUMBER=$(git branch | grep '*' | sed 's/* //' | tr -dc '0-9') | |
if [ "$2" == "message" ]; then | |
echo "Message given, we do not modify the git commit message" | |
exit 0 | |
fi | |
if [ "$2" == "merge" ] || [ "$2" == "squash" ]; then | |
echo "$2 commit, we do not edit the message" | |
exit 0 | |
fi | |
if [ -z "$ISSUE_NUMBER" ]; then | |
echo -n -e "\n# Current branch: $NAME" | cat - "$1" > .git-commit-msg-temp | |
else | |
echo -n -e "\n\nrefs #$ISSUE_NUMBER\n#Current branch: $NAME" | cat - "$1" > .git-commit-msg-temp | |
fi | |
cat .git-commit-msg-temp > "$1" | |
rm .git-commit-msg-temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment