Skip to content

Instantly share code, notes, and snippets.

@RyanMcG
Last active August 1, 2018 17:05
Show Gist options
  • Save RyanMcG/5775028 to your computer and use it in GitHub Desktop.
Save RyanMcG/5775028 to your computer and use it in GitHub Desktop.
A pre-commit hook for rails projects that scans for 'binding.pry', 'debugger' and diff artifacts and stops the commit if it finds any.
#!/bin/sh
COMMAND='git grep -n --cached'
ARGS='-e debugger -e "binding\.pry" -- app config db spec vendor script lib Rakefile Guardfile Capfile'
if eval "$COMMAND -q $ARGS" ; then
echo "You have a binding.pry or a debugger in a bad place.\n"
eval "$COMMAND $ARGS"
exit 1
fi
ARGS='-e "^<<<<<<< " -e "^>>>>>>> " -e "^=======$" -- app config db spec vendor script lib Rakefile Guardfile Capfile'
if eval "$COMMAND -q $ARGS" ; then
echo "You have some left over diff artifacts.\n"
eval "$COMMAND $ARGS"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment