Created
February 1, 2021 14:26
-
-
Save mallowigi/f5462f2db81078cec3e7e81e7b4181c4 to your computer and use it in GitHub Desktop.
Commit Message Hook
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 | |
# | |
# Automatically adds branch name and branch description to every commit message. | |
# | |
if [ -z "$BRANCHES_TO_SKIP" ]; then | |
BRANCHES_TO_SKIP=(master release-version) | |
fi | |
ALT_NAME=$(git branch | grep '*' | sed 's/* //')i | |
BRANCH_NAME=$(git symbolic-ref --short HEAD 2>/dev/null) | |
if [ -z $BRANCH_NAME ]; then BRANCH_NAME=ALT_NAME; fi | |
#DESCRIPTION=$(git config branch."$NAME".description) | |
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$") | |
echo "this is $(cat ${1})" | |
if ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $(cat "$1") == "[$BRANCH_NAME]"* ]] && ! [ -z "$BRANCH_NAME" ]; then | |
echo "[$BRANCH_NAME]: $(cat "${1}")" > "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment