VisualSVN Server提交前必须写日志和修改以往日志出错解决办法

来源:互联网 发布:蔡晓红淘宝 编辑:程序博客网 时间:2024/06/08 02:34

如果要求提交版本库时必须写日志,设置如下

VisualSVN Server下右键项目  “所有任务”》“Manage Hooks” 》选中Pre-commit hook然后edit编辑,添加如下代码

@echo off
::    
:: Stops commits that have empty log messages.
::

@echo off

setlocal

rem Subversion sends through the path to the repository and transaction id
set REPOS=%1
set TXN=%2

rem check for an empty log message
svnlook log %REPOS% -t %TXN% | findstr . > nul
if %errorlevel% gtr 0 (goto err) else exit 0

:err
echo. 1>&2
echo Your commit has been blocked because you didn't give any log message 1>&2
echo Please write a log message describing the purpose of your changes and 1>&2
echo then try committing again. -- Thank you 1>&2
exit 1

然后保存,就可以了,这个功能有多种实现方式,这是纯DOS命令的,他会在项目 hooks/下生成一个 pre-commit.cmd批处理文件

还有其他方法

CMD配合perl实现,还可以判断Log信息的最小长度,比较灵活,需要两个文件

pre-commit.cmd:

set REPOS=%1 
set REV=%2 
"C:\Perl\bin\perl.exe" "E:\Repositories\woodpecker\hooks\custom-pre-commit.pl" %REPOS% %REV%

custom-pre-commit.pl:

#!/usr/bin/perl# config section$minchars = 4; $svnlook = '"D:\Program Files\VisualSVN Server\bin\svnlook.exe"'; #--------------------------------------------$repos = $ARGV[0];$txn = $ARGV[1]; $comment = `$svnlook log -t "$txn" "$repos"`;chomp($comment); if ( length($comment) == 0 ) { print STDERR "A comment is required!"; exit(1); }elsif ( length($comment) < $minchars ) { print STDERR "Comment must be at least $minchars characters."; exit(1); } exit(0);

应为没装pear,所以这个方法我没有试过。

 

编辑以往版本日志的时候会报错

DAV request failed; it’s possible that the repository’s pre-revprop-change hook

either failed or is non-existent At least one property change failed; repository is uncahnaged

Error setting property “log”:

Repository has not been enabled to accept revision propchanges;

ask the administrator to create a pre-revprop-change hook

解决办法:

进入visualsvn管理界面

找到你的项目目录,右击选择中 “所有任务-》Manage Hooks”

选择 “Pre-revision property change hook”,然后点击下面的编辑

敲两个回车,然后点OK关闭就可以了。

其实就是在项目目录里的hooks子目录下创建了一个空白pre-revprop-change.cmd

就这么简单,还真的管用,真受不了是为啥了。

原创粉丝点击