1. 程式人生 > >SVN幾個有用的鉤子(windows下使用)

SVN幾個有用的鉤子(windows下使用)

1.強制提交時要寫日誌。複製下面程式碼,儲存為pre-commit.bat檔案,複製到hooks目錄下。 @echo off
set SVN_BINDIR="C:\Program Files\Subversion\bin"
setlocal
set REPOS=%1
set TXN=%2
rem check that logmessage contains at least 10 characters
%SVN_BINDIR%\svnlook log "D:\RepositorySVN\M31" "%REPOS%" -t "%TXN%" | findstr ".........." > nul
if %errorlevel% gtr 0 goto err
exit 0
:err
echo 提交日誌字元小於10個!退出提交! 1>&2
exit 1 2.修改日誌資訊。複製下面程式碼,儲存為pre-revprop-change.bat檔案,複製到hooks目錄下。 #每人可以修改自己的log日誌,而管理員li可以任意修改。
for /f "usebackq" %%k in (`svnlook author %1 -r%2`) do @set var=%%k if "%3" == "%var%" goto test
if "%3" == "li"    goto test
exit 1 :test
if "%4" == "svn:log" exit 0
echo Property '%4' cannot be changed >&2
exit 1