SVN 脚本钩子及使用说明
强制提交时写入日志信息
脚本名:pre-commit.bat
内容:
@echo off
set SVN_BINDIR=D:\"Program Files"\"VisualSVN Server"\bin"
setlocal
set REPOS=%1
set TXN=%2
rem check that logmessage contains at least 10 characters
%SVN_BINDIR%\svnlook log "%REPOS%" -t "%TXN%" | findstr ".........." > nul
if %errorlevel% gtr 0 goto err
exit 0
:err
echo 提交时必须填写更改日志!请重试 1>&2
exit 1
允许修改所有日志信息
脚本名:pre-revprop-change.bat
内容:
rem Only allow log messages to be changed.
if "%4" == "svn:log" exit 0
echo Property '%4' cannot be changed >&2
exit 1
只允许用户修改自己的日志信息
脚本名:pre-revprop-change.bat
内容:
set repos=%1
set rev=%2
set user=%3
set propname=%4
set action=%5
for /f "usebackq" %%k in (`svnlook author %repos% -r %rev%`) do @set var=%%k
set rightUser=0
if "%3" == "%superUser%" set rightUser=1
if "%3" == "%var%" set rightUser=1
if %rightUser% == 0 goto ERROR_USER
goto :SUCCESS_EXIT
:ERROR_USER
echo 只允许用户修改自己的日志 >&2
goto ERROR_EXIT
:ERROR_EXIT
exit 1
:SUCCESS_EXIT
exit 0