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

cd repository/hooks,找到pre-commit.tmpl文件,去掉后缀.tmpl, 编辑pre-commit文件:

1. windows: 重命名为pre-commit.bat
Java代码 复制代码  收藏代码
  1. @echo off   
  2. setlocal   
  3. set REPOS=%1  
  4. set TXN=%2  
  5. rem check that logmessage contains at least 10 characters   
  6. rem .....代表5个字符   
  7. svnlook log "%REPOS%" -t "%TXN%" | findstr ".........." > nul   
  8. if %errorlevel% gtr 0 goto err   
  9. exit 0  
  10. :err   
  11. echo Empty log message not allowed. Commit aborted! 1>&2  
  12. 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   
  1. REPOS="$1"  
  2. TXN="$2"  
  3. SVNLOOK=/usr/bin/svnlook   
  4. # check that logmessage contains at least 10 alphanumeric characters   
  5. LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | tr -d ' ' | wc -c`   
  6. if [ "$LOGMSG" -lt 10 ];   
  7. then   
  8.   echo -e "\nEmpty log message not allowed. Commit aborted!" 1>&2  
  9.   exit 1  
  10. fi  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值