Created
November 6, 2013 14:42
-
-
Save JanBe/7337120 to your computer and use it in GitHub Desktop.
Git pre-commit hook to prevent pry stuff from getting into the codebase
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
# Git pre-commit hook to check all staged files for pry references | |
# | |
# Installation | |
# | |
# ln -s /path/to/pre-commit.sh /path/to/project/.git/hooks/pre-commit | |
# | |
# Based on | |
# | |
# http://www.alexbevi.com/blog/2012/08/23/keeping-pry-breakpoints-out-of-git/ | |
# | |
PRY_PATTERN="require.+[\'\"]pry[\'\"]|binding\.pry" | |
# Redirect output to stderr. | |
exec 1>&2 | |
if git diff --cached | grep '^\+' | grep -q -E $PRY_PATTERN; then | |
echo "ERROR: There is left over pry stuff in this commit" | |
git diff --cached --name-only | xargs grep -n -H -E $PRY_PATTERN | |
exit 1 # reject | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've done something similar with eslint
useful for the
console
stuff and to check your code style etc.