Skip to content

Instantly share code, notes, and snippets.

View kbav's full-sized avatar

Kyle Bavender kbav

View GitHub Profile
@abalejr
abalejr / prepare-commit-msg
Created July 8, 2022 14:57
Append Issue Number to Commit Message
#!/bin/bash
FILE=$1
MESSAGE=$(cat $FILE)
TICKET=$(git rev-parse --abbrev-ref HEAD | grep -Eo '^(\w+/)?(\w+[-_])?[0-9]+' | grep -Eo '(\w+[-])?[0-9]+' | tr "[:lower:]" "[:upper:]")
if [[ $TICKET == "" || "$MESSAGE" == "$TICKET"* ]];then
exit 0;
fi
echo "$MESSAGE (#$TICKET)" > $FILE