Skip to content

Instantly share code, notes, and snippets.

@dmitryn
Created October 7, 2014 23:57
Show Gist options
  • Save dmitryn/2e882a871ff19f8ce1c4 to your computer and use it in GitHub Desktop.
Save dmitryn/2e882a871ff19f8ce1c4 to your computer and use it in GitHub Desktop.
GH issue number appender

Place this to .git/hooks/commit-msg in project root to append issue number from branch name to commit message.

#!/bin/sh
# Adds github issue number to commit message based on current branch name.
# Example: current branch '308-context-help', commit message 'fix bug',
# final commit message will be '#308 fix bug'
if [ "$NOPREFIX" ]; then
exit 0
fi
number=$(git branch | grep '*' | sed 's/* //' | cut -d'-' -f 1)
if [[ "$number" =~ ^[0-9]+$ ]] ; then
echo 'OBSLabs/virool#'"$number"' '$(cat "$1") > "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment