No more changes on Subversion tags
Tagging is a standard pattern when using Subversion. Tags are immutable because this pattern tells us it is immutable, but Subversion has no builtin mechanism to prevent changes on tags. It is just like any other directory, so it can be changed. Fortunately Subversion has a pre-commit hook and this hook can used to make tags truly immutable.
The idea behind it is that there can be no changes inside the tree of the tag, but there can be any operation on the tag itself. This Windows script does the trick.
SET REPOSITORY=%1% SET TRANSACTION=%2% SET ERROR=1 SET SUCCESS=0 SET SVNLOOK="C:\Program Files\VisualSVN Server\bin\svnlook" REM check if changes to a tag are committed %SVNLOOK% changed %REPOSITORY% -t %TRANSACTION% | findstr /r /i "^.*/tags/[^/]*/..*" IF %errorlevel% == 0 (GOTO CommitOnTagError) GOTO End :CommitOnTagError ECHO. 1>&2 ECHO Error: 1>&2 ECHO Changes to tags are not allowed. 1>&2 EXIT %ERROR% :End EXIT %SUCCESS%
Creating tags or branches for Subversion based on Hudson builds
Hudson has a builtin mechanism for tagging. Using this default mechanism helps a lot. However if you have multi-module jobs, you could still be stuck making the same changes in all those paths. Especially when you want to create branches instead of tags. Of course these manual changes are very errorprone. Especially when you are in a hurry. So it can be improved and that’s what this Ant script is about. Read more
Force comments on each commit in Subversion
When using version control it is important the comments are specified for each commit. This will help you and your colleagues a lot when trying to find out why what happened in the past. A lot of people tend to forget to fill in the comment when committing their changes. In Subversion comments for each commit can be forced by having the pre-commit hook on the repository. When you have this pre-commit hook the changes simply won’t be committed if no comment is specified.
Next is a sample for a pre-commit hook on a Windows Subversion server.
SET REPOSITORY=%1% SET TRANSACTION=%2% SET ERROR=1 SET SUCCESS=0 REM check if the commit does not have any comments svnlook log %REPOSITORY% -t %TRANSACTION% | findstr . > nul IF %errorlevel% gtr 0 (GOTO NoCommentError) EXIT %SUCCESS% :NoCommentError ECHO. 1>&2 ECHO Error: 1>&2 ECHO There is no comment specified for this commit. 1>&2 ECHO You must write a comment describing your changes. 1>&2 EXIT %ERROR%