Skip to content

Instantly share code, notes, and snippets.

@eqdw
Created June 4, 2012 18:40
Show Gist options
  • Save eqdw/2870108 to your computer and use it in GitHub Desktop.
Save eqdw/2870108 to your computer and use it in GitHub Desktop.
Prevent committing debugger statements
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
for FILE in `git diff-index --name-status $against -- | cut -c3-` ; do
# Check if the file contains 'debugger' or 'binding.pry'
if [ "grep 'debugger' $FILE" ]
then
echo $FILE ' contains a debug statement!'
exit 1
fi
if [ "grep 'binding.pry' $FILE" ]
then
echo $FILE ' contains a call to pry!'
exit 1
fi
done
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment