How to require commit messages in VisualSVN server?

后端 未结 10 1935
故里飘歌
故里飘歌 2020-12-07 12:00

We\'ve got VisualSVN Server set up as our Subversion server on Windows, and we use Ankhsvn + TortoiseSVN as clients on our workstations.

How can you configure the se

10条回答
  •  甜味超标
    2020-12-07 12:17

    I'm glad you asked this question. This is our pre-commit hook script written in common Windows Batch. It denies commit if the log message is less than 6 characters. Just put the pre-commit.bat to your hooks directory.

    pre-commit.bat

    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
    

提交回复
热议问题