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

来源:互联网 发布:最好的下载软件 编辑:程序博客网 时间:2024/06/06 06:36
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  


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  
原创粉丝点击