Last active
May 10, 2017 18:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 <[email protected]> # | |
# 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