我寫了一個在Windows上運行的SVN的預先提交鉤子腳本(.bat
)。我的SVN鉤子腳本有什麼問題----- pre-commit.bat?
的主要目的是:
- 檢查反轉日誌長度;
- 防止正常用戶刪除
[repo]/trunk/
文件夾; - 防止正常用戶刪除
[repo]/trunk/xxx/
文件夾;
但SVN總是說:
command syntax not correct (exitcode 255)
的代碼是在這裏:
@echo off
:: Stops commits that have empty log messages.
@echo off
setlocal
set REPOS=%1
set TXN=%2
Rem Check log length.
svnlook log -t "%TXN%" "%REPOS%" | findstr ".........." > nul
if %errorlevel% gtr 0 goto NoLog
@echo off
set Drop=No
Rem Check Delete operation on trunk
svnlook changed -t "%TXN%" "%Repos%" | findstr "^D[ ]*trunk//$"
if %ERRORLEVEL% == 0 (set Drop=Yes)
Rem Check Delete operation on subdirectory of Trunk
svnlook changed -t "%TXN%" "%Repos%" | findstr "^D[ ]*trunk/[.]*//$"
if %ERRORLEVEL% == 0 (set Drop=Yes)
if Drop == Yes
(goto DropTrunk)
else
(exit 0)
:NoLog
echo You must inpu reversion log, and not less than 10 characters! 1>&2
exit 1
:DropTrunk
echo Only admin can delete the trunk directory and its subdirectory! 1>&2
exit 1
'如果Drop == Yes'永遠不會是真的。也許你的意思是'%Drop%'? – 2014-11-03 02:06:34