Last active
December 27, 2016 13:51
-
-
Save rex/223b4be50285f6b8b3e06dea50d15887 to your computer and use it in GitHub Desktop.
Git pre-commit hook that will detect COMMITFAIL, @COMMITFAIL, NOCOMMIT, or @nocommit and fail the commit.
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 | |
echo "Arguments:" | |
echo $@ | |
echo "---" | |
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 |
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
- id: commitfail | |
name: COMMITFAIL | |
description: Detect COMMITFAIL, @COMMITFAIL, NOCOMMIT, or @NOCOMMIT and fail the commit. | |
entry: commitfail-pre-hook.sh | |
language: script | |
files: '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment