Created
January 10, 2017 16:17
-
-
Save rzymek/969fd17583811addcc579af04e412a9f to your computer and use it in GitHub Desktop.
NOCOMMIT pre-commit hook
This file contains hidden or 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 | |
# Place in .git/hooks | |
# chmod +x .git/hooks/pre-commit | |
FILES_PATTERN='(\..+)?$' | |
FORBIDDEN='(@?NOCOMMIT|@?COMMITFAIL)' | |
if ( git diff --cached --name-only | grep -E $FILES_PATTERN | xargs grep -E --with-filename -n $FORBIDDEN ); then | |
echo "ERROR: @COMMITFAIL or @NOCOMMIT found. Exiting to save you from yourself." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment