#!/bin/sh
# Save this snipped in both: .git/hooks/prepare-commit-msg and .git/hooks/commit-msg
# Make it executable: chmod u+x .git/hooks/prepare-commit-msg .git/hooks/commit-msg
COMMIT_MSG_FILE=$1
if ! grep -v "^\s*[#;]" $COMMIT_MSG_FILE | grep -Eq 'PP-[0-9]{4,5}\b'; then
BRANCH=$(git branch | grep '*' | sed 's/* //')
TICKET="$(echo ${BRANCH} | cut -d'-' -f1)-$(echo ${BRANCH} | cut -d'-' -f2)"
echo "[$TICKET] $(cat $COMMIT_MSG_FILE)" > $COMMIT_MSG_FILE
fi
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter