Last active
December 10, 2015 02:18
-
-
Save naan/4366407 to your computer and use it in GitHub Desktop.
git pre-commit.sh for avoiding commit `console.*log` and `binding.pry`
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/sh | |
function check_forbidden_code { | |
git diff --cached --name-only | grep -E $1 > /dev/null || return | |
git diff --cached --name-only | grep -E $1 |\ | |
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -E -n $2 && echo "COMMIT REJECTED Found '$2' references. Please remove them before commiting" && exit 1 | |
} | |
JS_FILES_PATTERN='\.(js|coffee)(\..+)?$' | |
JS_FORBIDDEN='(console\..*log|debugger)' | |
check_forbidden_code $JS_FILES_PATTERN $JS_FORBIDDEN | |
RB_FILES_PATTERN='\.rb$' | |
RB_FORBIDDEN='binding.pry' | |
check_forbidden_code $RB_FILES_PATTERN $RB_FORBIDDEN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated. check
debugger
too.