您的位置:首页 > 运维架构 > Linux

【SVN版本管理必备】svn hook(强制要求提交注释必须多于X个字)

2012-10-13 14:40 609 查看
cd repository/hooks,找到pre-commit.tmpl文件,去掉后缀.tmpl, 编辑pre-commit文件:

1. windows: 重命名为pre-commit.bat

Java代码


 




@echo off   
setlocal   
set REPOS=%1  
set TXN=%2  
rem check that logmessage contains at least 10 characters   
rem .....代表5个字符   
svnlook log "%REPOS%" -t "%TXN%" | findstr ".........." > nul   
if %errorlevel% gtr 0 goto err   
exit 0  
:err   
echo Empty log message not allowed. Commit aborted! 1>&2  
exit 1  

@echo off
setlocal
set REPOS=%1
set TXN=%2
rem check that logmessage contains at least 10 characters
rem .....代表5个字符
svnlook log "%REPOS%" -t "%TXN%" | findstr ".........." > nul
if %errorlevel% gtr 0 goto err
exit 0
:err
echo Empty log message not allowed. Commit aborted! 1>&2
exit 1


2. linux:chmod u+x pre-commit

Java代码
#!/bin/sh   

REPOS="$1"  
TXN="$2"  
SVNLOOK=/usr/bin/svnlook   
# check that logmessage contains at least 10 alphanumeric characters   
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | tr -d ' ' | wc -c`   
if [ "$LOGMSG" -lt 10 ];   
then   
  echo -e "\nEmpty log message not allowed. Commit aborted!" 1>&2  
  exit 1  
fi  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  svn hook java windows linux