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 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
# 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 |
I've done something similar with eslint
#!/bin/zsh
function lintit () {
OUTPUT=$(git diff --name-only | grep -E '(.js)$')
a=("${(f)OUTPUT}")
e=$(eslint -c eslint.json $a)
echo $e
if [[ "$e" != *"0 problems"* ]]; then
echo "ERROR: Check eslint hints."
exit 1 # reject
fi
}
lintit
useful for the console
stuff and to check your code style etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding
console.log
anddebugger
would be useful as well.And
:focus
respectivelyfocus: true
, of course.