Last active
December 4, 2018 10:59
-
-
Save hamzaPixl/34817ca39aeb140b44070a728613310e to your computer and use it in GitHub Desktop.
Put the tag present in the name of the branch in your 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
| { | |
| "hooks": { | |
| "prepare-commit-msg": "hooks/prepare-commit-msg.sh ${HUSKY_GIT_PARAMS}" | |
| } | |
| } |
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 | |
| BRANCHES_TO_SKIP=(master development production staging test) | |
| BRANCH=$(git symbolic-ref --short HEAD) | |
| COMMIT_MESSAGE=$1 | |
| echo "Branch $(cat $BRANCH)" | |
| echo "Changing the commit message:" | |
| echo "$(cat $COMMIT_MESSAGE)" | |
| BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH$") | |
| if ! [[ $BRANCH_EXCLUDED -eq 1 ]]; then | |
| TICKET=$(echo $BRANCH | grep -o -E '[A-Za-z]+-[0-9]+' | head -1) | |
| if [ ! -z $TICKET ]; then | |
| printf "[$TICKET] $(cat $COMMIT_MESSAGE)" > $COMMIT_MESSAGE | |
| else | |
| printf "[TAG] $(cat $COMMIT_MESSAGE)" > $COMMIT_MESSAGE | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment