在windwos平台上强制SVN提交添加日志的方法,通过网络搜索方法一般都提示为这样写:
2、到版本库中hooks目录下,将pre-commit.tmpl文件复制为pre-commit.bat文件,然后将pre-commit.bat 文件内容改为: 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
摘自:http://www.cnblogs.com/jamin/archive/2008/11/15/1334091.html
但按照此方法写了以后,会发现提交时报错:
Commit blocked by pre-commit hook (exit code 1) with output: svnlook: E205000: Try ‘svnlook help’ for more info svnlook: E205000: Too many arguments given
开始时,想到可能是脚本错误,最后翻看了 SVNLOOK LOG的提交方法,发现方法是对的。后按照SVNLOOK的提示:参数太多,怀疑是参数问题,改造调试脚本,让它打印出SVNLOOK调用的参数。结果发现,参数里带了双重引号。去掉%TXN%前的引号,继续调试。提交成功。现将调试过的代码发布如下:
@echo off
setlocal
set REPOS=%1
set TXN=%2
set SVNLOOK=”C:\Program Files\VisualSVN Server\bin\svnlook.exe” — 此处,改为你的实际SVNlook地址
rem check that logmessage should contains at least 10 characters
rem 曲风荷修改 2012年3月15日 redcn2004@gmail.com
%SVNLOOK% log %REPOS% -t %TXN% | findstr “……….”> nul
if %errorlevel% gtr 0 goto err
exit 0
:err
echo 不允许空日志,提交中断(需要不小于10个字符或5个汉字的日志)! 1>&2
exit 1