Created
October 6, 2017 13:39
-
-
Save danjohnson95/163f3976acbf5cb2a52b8d2ba8bdf291 to your computer and use it in GitHub Desktop.
A git hook for enforcing a commit message standard
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/bash | |
# | |
# The link to the wiki page detailing these standards | |
url='https://github.com/designmynight/dmn/wiki/Semantic-Commit-Messages' | |
# The regular expression in which the commit message should match | |
regex='^(fix|feat|chore|refactor|test|style|docs)(:\s)([\S].{1,60}[\S])' | |
# What we'll say | |
error_msg="Aborting commit due to incorrect message format.\nPlease see $url" | |
if ! grep -iqE "$regex" "$1"; then | |
echo 'Aborting commit due to incorrect message format.' >&2 | |
echo "Please see $url" >&2 | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment