SVN强制写日志

http://www.cnblogs.com/jamin/archive/2008/11/15/1334091.html

Windows环境

windows下svn限制强制写日志及只能修改日志脚本,下面是我在svn1.5 下经过测试的绝对可用的脚本,特把正确的脚本分享给大家,希望能给也需要设置此功能,被一些不正确的脚本搞的头大的朋友一些帮助。

找到版本库中hooks目录下,将pre-revprop-change.tmpl文件复制为pre-revprop-change.bat文件,然后将pre-revprop-change.ba文件内容改为:

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
setlocal
set REPOS=%1
set TXN=%2
rem check that logmessage contains at least 5 characters
svnlook log "%REPOS%" -t "%TXN%" | findstr ".........." > nul
if %errorlevel% gtr 0 goto err
exit 0
:err
echo 提交必须写日志!>&2
exit 1

Linux

pre-commit.tmpl,然后更名pre-commit并加上执行权限:

#!/bin/sh

REPOS="$1"
TXN="$2"

RES="OK"
# Make sure that the log message contains some text.
SVNLOOK=/app/subversion/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | egrep "[^[:space:]]+" >/dev/null || unset RES
if [ "$RES" != "OK" ]
then
    echo "You must input some comments for you commit" >&2
    exit 1
fi

# All checks passed, so allow the commit.
exit 0