Forked from branonbarrett/prepare-commit-message.sh
Last active
November 19, 2021 16:20
-
-
Save a88zach/cfd4b52bee36a9df6ad71ea9a2b6d002 to your computer and use it in GitHub Desktop.
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 | |
# modified from https://gist.github.com/bartoszmajsak/1396344 | |
if [ -z "$BRANCHES_TO_SKIP" ]; then | |
BRANCHES_TO_SKIP=(master main develop test release) | |
fi | |
BRANCH_NAME=$(git symbolic-ref --short HEAD) | |
BRANCH_TYPE=$(printf "${BRANCH_NAME%/*}") | |
BRANCH_CONTEXT=$(printf "${BRANCH_NAME##*/}") | |
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$") | |
if [ -n "$BRANCH_TYPE" ] && [ -n "$BRANCH_CONTEXT" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]]; then | |
sed -i.bak -e "1s/^/$BRANCH_TYPE($BRANCH_CONTEXT) /" $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To Install: