Created
October 4, 2010 12:40
-
-
Save iiska/609631 to your computer and use it in GitHub Desktop.
Refuse commit when there are debug code present.
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 | |
# | |
# Aborts commit if grepping diff encounters JS or Ruby debug lines. | |
has_console_log=$(git diff --cached | grep '^\+\s*console\.log\(.*\)') | |
has_console_dir=$(git diff --cached | grep '^\+\s*console\.dir\(.*\)') | |
has_ruby_debug=$(git diff --cached | grep "^\+\s*\(require \['\"\]ruby-debug\['\"\];\?\)\?\s*debugger") | |
if [ "$has_console_log" != "" ] | |
then | |
echo "ERROR: You have console.log in your commit." | |
exit 1 | |
fi | |
if [ "$has_console_dir" != "" ] | |
then | |
echo "ERROR: You have console.dir in your commit." | |
exit 1 | |
fi | |
if [ "$has_ruby_debug" != "" ] | |
then | |
echo "ERROR: You have \"require 'ruby-debug'\" or \"debugger\" in your commit." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment