Skip to content

Instantly share code, notes, and snippets.

@nacin
Created April 6, 2012 21:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nacin/2323060 to your computer and use it in GitHub Desktop.
Save nacin/2323060 to your computer and use it in GitHub Desktop.
Nacin's SVN override
# SVN override to prevent commits that try to implicitly commit more than one file.
# Has weaned me off of svn ci -m very effectively. I now almost always use svn ci,
# which usually results in me writing longer and more helpful commit messages.
# Also, it prevents me from committing unrelated code, so there's that.
#
# Also checks for error_log, var_dump, and console.log, and rejects these commits.
function svn() {
if [ "$1" == "ci" ] && [ "$2" == "-m" ] && [ -z "$4" ] && [ "$(svn stat --ignore-externals | grep '^[^?X]' | wc -l | awk '{print $1}')" -gt 1 ]; then
svn stat --ignore-externals | grep '^[^?X]'
echo ""
echo $3
echo ""
echo "Unbounded commit... What are you doing, man?"
return
elif [ "$1" == "ci" ] && [ "$(svn diff | grep -E '^\+.*(error_log|var_dump|console\.log)' | wc -l | awk '{print $1}')" -gt 0 ]; then
echo "You left in some debug cruft."
return
fi
/usr/bin/svn "$@"
}
@nacin
Copy link
Author

nacin commented Apr 6, 2012

Some other things I'd like to add:

  • Reject when diffs that have ^+._var_dump() or ^+._error_log() in them.
  • Reject commits that reference a ticket that doesn't exist (indicative of a typo).

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