设置SVN服务器强制填写日志

本文介绍了如何在SVN仓库的hooks中修改pre-commit模板文件,以确保提交时的日志包含有意义的内容,防止空日志提交,并通过设置可执行权限和执行逻辑检查实现此目的。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Linux SVN Server 
SVN Server在每个仓库中的hooks里都有个pre-commit.tmpl文件,修改这个文件为pre-commit并添加可执行权限:chmod +x pre-commit。pre-commit文件内容如下:

REPOS=”$1″ 
TXN=”$2″

# Make sure that the log message contains some text. 
SVNLOOK=/usr/bin/svnlook 
LOGMSG=`$SVNLOOK log -t “$TXN” “$REPOS” | grep “[a-zA-Z0-9]” | wc -c`

if [ "$LOGMSG" -lt 10 ]; then 
echo -e “Please provide a meaningful comment when committing changes.” 1>&2 
exit 1 
fi

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

Windows SVN Server 
同样在每个仓库的hooks目录下有个pre-commit.tmpl,修改为pre-commit.bat

@echo off
::
:: Stops commits that have empty log messages.
::
@echo off
set svnlook="E:\csvn\bin\svnlook.exe"
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 Log Message不能为空, 请填写JIRA系统相应的Key+主题! 例如: XDYY-1 系统性能测试 1>&2
exit 1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值