Monday, September 12, 2011

Allowing changes in subversion log messages or comments

When you commit your change to a subversion repository you have an option to change the comment you use:
svn propset --revprop -r 15125 svn:log "Editing this comment with more detail, blah, blah ..."

There is a hook script template that you could use to allow this but there is a reason why the default template should not be used as is. It is dangerous to be able to affect good comments with garbage if you just make a mistake with the version number but the most dangerous of all is that you could change comments done by a different user!!! From a GUI like Eclipse or Netbeans it is harder to make a mistake like the first one of course, however you should protect subversion so log changes are restricted to the owner of the commit.

Use the below to achieve it (Linux, if Windows translate to DOS)
$ sudo vi /var/local/svn/

owner=`svnlook author -r "$REV" "$REPOS"`
if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" -a "$owner" = "$USER" ]; then exit 0; fi

echo "Changing revision properties other than svn:log is prohibited and you must be the owner($owner) to change $REPOS@$REV" >&2
exit 1 
$sudo chmod +x  /var/local/svn/

No comments: