Simple Git Bash Hook to Enforce Issue Numbers in Push Message

$ nano update

#!/bin/sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin

issue_number=$(git log –pretty=%s $2..$3 | egrep -m 1 ‘#[0-9]+’)
if [ -z “$issue_number” ]; then
echo “Error: Commit message must include issue number.”
echo ” $issue_number”
exit 1
fi

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s