Last active
December 29, 2015 17:29
-
-
Save anscii/7704518 to your computer and use it in GitHub Desktop.
Manual developer-side svn pre-commit hook. Put it inside your .bashrc and use "svnci -m 'some message' somefile anotherfile" instead of usual "svn ci -m 'some message' somefile anotherfile". All arguments for 'svnci' will be carefully redirected to actual 'svn ci' call. The function will 'rise error' if your diff contains var_dump or other debug…
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
svnci() { | |
greprc=$(svn diff | grep -wc -E '(echo|var_dump|print_r|var_export)') | |
if [[ $greprc == 1 ]] ; then | |
echo '###############################' | |
echo '### WARNING! DEBUG DETECTED ###' | |
echo '###############################' | |
svn diff | grep -E '(echo|var_dump|print_r|var_export|\+\+\+)' | |
else | |
if [[ $greprc == 0 ]] ; then | |
args='' | |
# carefully save quoted arguments (for example, commit message) | |
whitespace="[[:space:]]" | |
for i in "$@" | |
do | |
if [[ $i =~ $whitespace ]] | |
then | |
i=\"$i\" | |
fi | |
args="$args $i" | |
done | |
cmd="svn ci $args" | |
eval $cmd | |
else | |
echo Some sort of error | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment