Skip to content

Instantly share code, notes, and snippets.

@shaunburch
Last active February 21, 2019 16:14
Show Gist options
  • Save shaunburch/ff87c0e1bfb08f0c67e0ae2fac21468b to your computer and use it in GitHub Desktop.
Save shaunburch/ff87c0e1bfb08f0c67e0ae2fac21468b to your computer and use it in GitHub Desktop.
Git hook to prepend branch & issue number to commits
#!/bin/sh
# Author: rmcdaniel
BRANCH_NAME=$(git symbolic-ref --short HEAD)
STORY_NUMBER=$(echo $BRANCH_NAME | sed -n 's/^.*\/\(.*-[0-9]*\)#.*/\1/p')
if [ x != x${STORY_NUMBER} ]; then
sed -i.back "1s/^/$STORY_NUMBER /" "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment