Created
June 8, 2016 14:14
-
-
Save ironprice91/fca6997834f56a1201164dcb470690f8 to your computer and use it in GitHub Desktop.
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 | |
| MSG_FILE=$1 | |
| TYPE_STR=$2 | |
| MSG_STR=$(cat ${MSG_FILE}) | |
| BRANCH_NAME=$(git branch | grep '*' | sed 's/* //') | |
| TICKET_NUMBER=$(git symbolic-ref --short HEAD) | |
| TICKET_NUMBER="${TICKET_NUMBER##*/}" | |
| if [ $BRANCH_NAME != '(no branch)' ] && [ "${TYPE_STR}" = "message" ]; then | |
| echo -e "\nChecking commit log...\nMessage Type: ${TYPE_STR}\n" | |
| if [[ "${MSG_STR}" =~ ^(TICKET\-) ]]; then | |
| echo "Commit log valid." | |
| elif [[ "${TICKET_NUMBER}" =~ ^(TICKET\-) ]]; then | |
| echo -e "Commiting to branch $TICKET_NUMBER" | |
| sed -i .bak -e "1s/^/$TICKET_NUMBER :: /" $1 | |
| else | |
| echo -e "Error: Your commit log must start with a JIRA ticket!\n" | |
| exit 1; | |
| fi | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment