Created
December 18, 2012 03:48
-
-
Save yuhonas/4324830 to your computer and use it in GitHub Desktop.
GIT Pre-Commit hook to prevent silly commits of binding.pry/debugger
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 | |
# GIT Pre-Commit hook to prevent silly commits of binding.pry/debugger | |
# Based off http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes | |
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 | |
# Redirect output to stderr. | |
exec 1>&2 | |
DEBUGGERS_REGEX="binding\.pry|debugger" | |
DIFF_SEARCH=$(git diff-index --name-only --cached $AGAINST -G $DEBUGGERS_REGEX --exit-code) | |
if [ "$DIFF_SEARCH" ]; then | |
echo | |
echo "The following files match the debuggers regex /$DEBUGGERS_REGEX/ [$0]" | |
echo "------------------------------------------------------" | |
echo | |
printf "$DIFF_SEARCH" | |
echo | |
exit 1 | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment