Skip to content

Instantly share code, notes, and snippets.

@solocommand
Last active December 17, 2015 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solocommand/5542878 to your computer and use it in GitHub Desktop.
Save solocommand/5542878 to your computer and use it in GitHub Desktop.
Hook to force commit messages to start with JIRA issue identifiers
#!/bin/bash
regex='^[A-Z]{2,6}-[0-9]{1,8}\s'
message="$(sed 's/^#.*//' $1 | grep -v '^$')"
if [[ $message =~ $regex ]] ; then
echo -e >&2 "\e[0;32mCommit linked issue\e[m ${BASH_REMATCH[0]}"
else
echo -e >&2 "\e[0;31mCommit failed: Invalid JIRA Key: $message\e[m"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment