Skip to content

Instantly share code, notes, and snippets.

@kiela
Last active December 31, 2015 13:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiela/7992960 to your computer and use it in GitHub Desktop.
Save kiela/7992960 to your computer and use it in GitHub Desktop.
Add branch name at the beginning of commit message if branch name starts with WEB or OP or SEC or FM
#!/bin/sh
branch=$(git symbolic-ref HEAD | awk -F/ '{ if($3 ~ /^(WEB|OP|DEVOPS|SEC|FM|PS|DAT|AD)-[[:digit:]]/) print $3 }' | awk -F"_" '{ if($1) print $1 }')
if [ -n "$branch" ]; then
sed -i "1 s/^/$branch: /" $1
sed -i '/'$branch\:'/a \\nIssue: https://acorns.atlassian.net/browse/'$branch $1
fi
wget https://gist.github.com/kiela/7992960/raw/f158458c63cca6ac413ea13abb6d0e643d0585f3/commit-msg -O .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment