Skip to content

Instantly share code, notes, and snippets.

@dchersey
Last active October 27, 2016 20:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dchersey/3e0bfba541ca7d1bd4c8e020330d697b to your computer and use it in GitHub Desktop.
Save dchersey/3e0bfba541ca7d1bd4c8e020330d697b to your computer and use it in GitHub Desktop.
commit hook to detect presence of rubymotion logging statements
#!/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
@dchersey
Copy link
Author

dchersey commented Oct 25, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment