Skip to content

Instantly share code, notes, and snippets.

@anscii
Last active December 29, 2015 17:29
Show Gist options
  • Save anscii/7704518 to your computer and use it in GitHub Desktop.
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…
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