Skip to content

Instantly share code, notes, and snippets.

@kentokento
Created October 28, 2014 17:28
Show Gist options
  • Save kentokento/750f0829eef5f712477a to your computer and use it in GitHub Desktop.
Save kentokento/750f0829eef5f712477a to your computer and use it in GitHub Desktop.
prepare-commit-msg
#!/bin/sh
if [ "$2" = "message" -o "$2" = "" ] ; then
msg="`cat .git/COMMIT_EDITMSG`"
branch=`git symbolic-ref HEAD 2>/dev/null`
if [ ! -n "`echo "$branch" | sed -e "s/.*\///g" | sed -e "s/[0-9]//g"`" ] ; then
header="`echo $branch | sed -e "s/.*\/\([0-9]\+\)$/PAIRS-\1/g"` "
if [ "$header" = " " ] ; then
echo "$msg" > $1
else
echo "$header$msg" > $1
fi
else
echo "$msg" > $1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment