Skip to content

Instantly share code, notes, and snippets.

@EpeeCheeze
Created November 14, 2011 18:57
Show Gist options
  • Save EpeeCheeze/1364770 to your computer and use it in GitHub Desktop.
Save EpeeCheeze/1364770 to your computer and use it in GitHub Desktop.
Create a diff of code only if there is no debug code present
#!/bin/bash
#For creating a code review diff. Making sure that no debugging code is located in the diff.
#This file will not create the diff if there are dump, print_r or NOCOMMIT statements.
#As echo and alert statements may be valid code, a warning is generated and a diff is made.
cd ~/whitelabel
branchName=$2
diffName=$1
diff=$(git diff $branchName)
if [ ${#diff} -eq 0 ]; then
echo There is no difference
exit
fi
dump=$(git diff $branchName | egrep 'dump|print_r|NOCOMMIT|console.log|die|{debug}')
if [ ${#dump} -gt 0 ]; then
echo $dump \n
echo You have debugging code in your diff
else
warnings=$(git diff $branchName | egrep 'echo|alert')
if [ ${#warnings} -gt 0 ]; then
echo $warnings \n
echo Please make sure that these are not for debugging
else
echo No Debugging code
fi
git diff $branchName > ~/Diff/$1
echo ~/Diff/$1 created
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment