Require comment / message on all SVN commits for Visual SVN Server

(I've been posting a lot the last few days!)

Something that drives me nuts is not having a comment or message when looking at SVN history. It's impossible to know what went on. Even a bad comment is better than no comment.

SVN hooks are a great way to solve this. If we make a pre-commit.bat file that checks the commit data for a comment, returns an error code of 1 if it wasn't found (with some text) or returns 0 if the comment is there.

Check out the pre-commit hook that I found online (thanks, Anuj Gakhar!) or check out the hook below.

@echo off

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TXN=%2

rem check for an empty log message
svnlook log %REPOS% -t %TXN% | findstr . > nul
if %errorlevel% gtr 0 (goto err) else exit 0

echo. 1>&2
echo A log message or comment is required to commit 1>&2
exit 1

This works perfectly except for 1 downfall -- you have to distribute it in every freaking repository! Below is the windows batch solution I came up with to solve that problem. Pretty straight forward, but thought I'd share for those less inclined to dig through archaic windows batch programming references.

Just create a batch file of the following & schedule it to run however often you want.

:: ------ SVN Deploy Hooks ------
:: ----- by Mark Kockerbeck ----

:: ------ Configuration ---------
SET HookDirectory=C:\CommonHooks
SET RepositoryDirectory=C:\Repositories
:: ------ /Configuration --------

pushd %HookDirectory%
for /r %%i in (*) do (
for /D %%j in (%RepositoryDirectory%\*) do (
echo Copying %%i to %%j\hooks\
copy %%i %%j\hooks\

No comments: