Last active
October 27, 2016 20:33
-
-
Save dchersey/3e0bfba541ca7d1bd4c8e020330d697b to your computer and use it in GitHub Desktop.
commit hook to detect presence of rubymotion logging statements
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
#!/bin/sh | |
# Redirect output to stderr. | |
exec 1>&2 | |
# enable user input | |
exec < /dev/tty | |
consoleregexp='^[^#]*mp[^a-zA-Z0-9]' | |
# CHECK | |
if test $(git diff --cached | grep $consoleregexp | grep + | wc -l) != 0 | |
then | |
exec git diff --cached | grep $consoleregexp | grep + | |
read -p "There is some logging code in your modifications. Are you sure want to continue? (y/n)" yn | |
echo $yn | grep ^[Yy]$ | |
if [ $? -eq 0 ] | |
then | |
exit 0; #THE USER WANTS TO CONTINUE | |
else | |
exit 1; # THE USER DONT WANT TO CONTINUE SO ROLLBACK | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
place this in your .git/hooks directory and chmod+x
Every time you commit (from the command line) it will prompt you if you have uncommented logging statements in your rubymotion code. See also https://gist.github.com/dchersey/4ca2c983602375aedcc121e482236ddc if you want to consciously keep logging code around.