Validating commit log messages in VisualSVN Server

If you are using Visual SVN server 3.9 You can add the pre-commit hook using the following steps 1.Take the properties of the SVN project and click pre-commit hook from Hooks tab

enter image description here

Add the following command to the box. Here change the --min-size

"%VISUALSVN_SERVER%\bin\VisualSVNServerHooks.exe" ^
    check-logmessage "%1" -t "%2" ^
    --min-size 10
    IF ERRORLEVEL 1 exit /b 1

If you are using another version of Visual SVN you can add the below code.

setlocal enabledelayedexpansion

set REPOS=%1
set TXN=%2

set SVNLOOK="%VISUALSVN_SERVER%\bin\svnlook.exe"

SET M=

REM Concatenate all the lines in the commit message
FOR /F "usebackq delims==" %%g IN (`%SVNLOOK% log -t %TXN% %REPOS%`) DO SET M=!M!%%g

REM Make sure M is defined
SET M=0%M%

REM Here the 6 is the length we require
IF NOT "%M:~6,1%"=="" goto NORMAL_EXIT

:ERROR_TOO_SHORT
echo "Commit note must be at least 6 letters" >&2
goto ERROR_EXIT

:ERROR_EXIT
exit /b 1

REM All checks passed, so allow the commit.
:NORMAL_EXIT
exit 0

enter image description here

Comments