Created
December 14, 2020 19:26
-
-
Save john-humi/f1479514e7ced759ea95a478abb2911e 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/sh | |
| # Checks if current branch matches JIRA pattern (ABC-1234-anything), then adds ABC-1234 to start of commit message. | |
| BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *') | |
| REGEX='^([a-zA-Z]{3}-[0-9]+)-*' | |
| if [ -n "$BRANCH_NAME" ]; then | |
| [[ $BRANCH_NAME =~ $REGEX ]] | |
| if [ -n "$BASH_REMATCH" ]; then | |
| echo "${BASH_REMATCH[1]} $(cat $1)" > $1 | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment