【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  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章