Last active
June 6, 2017 20:05
-
-
Save jasondscott/e86e69e1501a401bf4a9ff43b401f76f to your computer and use it in GitHub Desktop.
pre-commit hook
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
echo "Running debugger check" | |
FILES=$(git diff --cached --name-only HEAD) | |
RED='\x1B[0;31m'; | |
DEBUG_COMMANDS='debugger|console\.log|binding\.pry' | |
# Adding /dev/null so that grep reports file name when only one file is given | |
ERRORS=$(grep -E --line-number $DEBUG_COMMANDS $FILES /dev/null) | |
if [ -n "$ERRORS" ]; then | |
echo "${ERRORS}" | |
echo "${RED}Commit was rejected because it contains debug statements." | |
exit 1 | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.git/hooks/
chmod +x pre-commit