Skip to content

Instantly share code, notes, and snippets.

@nanotaboada
Last active May 10, 2017 18:37
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 nanotaboada/fbf52d9f74c88412de4a to your computer and use it in GitHub Desktop.
Save nanotaboada/fbf52d9f74c88412de4a to your computer and use it in GitHub Desktop.
Git commit-msg hook that prevents committing with a comment that does not include a Jira key
#!/bin/sh
# ---------------------------------------------------------------------------- #
# Filename: .git/hooks/commit-msg #
# Description: Git commit-msg hook that prevents committing with a comment #
# that does not include a Jira key. #
# Created by: Nano Taboada <nanotaboada@msn.com> #
# Version: 0.1.0 #
# License: http://opensource.org/licenses/MIT #
# Last updated: Jun 30, 2015 #
# ---------------------------------------------------------------------------- #
# Replace this with your Project Key
JIRA_KEY="KEY-"
test "" != "$(grep "${JIRA_KEY}" "$1")" || {
echo >&2 "[ERROR] Invalid message format!"
echo >&2 "[ERROR] Commit message must start with JIRA Issue (e.g.: KEY-123)"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment