Skip to content

Instantly share code, notes, and snippets.

@rzymek
Created January 10, 2017 16:17
Show Gist options
  • Save rzymek/969fd17583811addcc579af04e412a9f to your computer and use it in GitHub Desktop.
Save rzymek/969fd17583811addcc579af04e412a9f to your computer and use it in GitHub Desktop.
NOCOMMIT pre-commit hook
#!/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