什麼樣的鉤子指令碼是人們使用的Subversion?只是一般的想法,但程式碼也很棒!
最佳答案
我正在使用pre-revprop-change
鉤子,允許在執行提交後實際返回並編輯註釋和此類資訊.如果提交註釋中缺少/錯誤資訊,這是非常有用的.
這裡我為Windows NT或以後釋出pre-revprop-change.bat
批處理檔案...
當然可以透過更多的修改來加強它。
post-revprop-change.cmd
從它備份舊的snv:log
在某處或只是將其附加到新的日誌...
唯一棘手的部分是能夠實際解析stdin
批處理檔案...這是用FIND.EXE
命令完成的.
另一個是,我從其他使用者收到了使用/b
與exit
命令的問題報告.如果錯誤案例行為不好,您可能需要在特定應用程式中刪除/b
.
@ECHO OFF
set repos=%1
set rev=%2
set user=%3
set propname=%4
set action=%5
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Only allow changes to svn:log. The author, date and other revision
:: properties cannot be changed
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if /I not '%propname%'=='svn:log' goto ERROR_PROPNAME
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Only allow modifications to svn:log (no addition/overwrite or deletion)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if /I not '%action%'=='M' goto ERROR_ACTION
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Make sure that the new svn:log message contains some text.
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set bIsEmpty=true
for /f "tokens=*" %%g in ('find /V ""') do (
set bIsEmpty=false
)
if '%bIsEmpty%'=='true' goto ERROR_EMPTY
goto :eof
:ERROR_EMPTY
echo Empty svn:log properties are not allowed. >&2
goto ERROR_EXIT
:ERROR_PROPNAME
echo Only changes to svn:log revision properties are allowed. >&2
goto ERROR_EXIT
:ERROR_ACTION
echo Only modifications to svn:log revision properties are allowed. >&2
goto ERROR_EXIT
:ERROR_EXIT
exit /b 1
相同標籤的其他問題
上一個問題:從網頁解析連結的正則表示式?