Skip to content

Instantly share code, notes, and snippets.

View michaelwoods's full-sized avatar

Michael Woods michaelwoods

View GitHub Profile
@michaelwoods
michaelwoods / prepare-commit-msg.sh
Last active July 16, 2018 15:30 — forked from bartoszmajsak/prepare-commit-msg.sh
Regex matching of JIRA story keys to prepend git commits.
#!/bin/bash
STORY_KEY=$(git symbolic-ref --short HEAD | grep -Eo '^[a-zA-Z0-9]{3,}[-_][0-9]{1,5}' | awk '{sub(/_/, "-"); print toupper($0)}')
if [ -n "$STORY_KEY" ]; then
sed -i.bak -e "1s/^/[$STORY_KEY] /" $1
fi