Common Types of Subversion Hooks

前端 未结 16 2176
無奈伤痛
無奈伤痛 2020-11-28 04:01

What kinds of hook scripts are people using for Subversion? Just general ideas but code would be great too!

16条回答
  •  余生分开走
    2020-11-28 04:34

    Windows pre-commit hook to check that log contains something.

    @ECHO OFF
    setlocal
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Get subversion arguments
    set repos=%~1
    set txn=%2
    
    :::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Set some variables
    set svnlookparam="%repos%" -t %txn%
    
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :: Make sure that the new svn:log message contains some text.
    set bIsEmpty=true
    for /f "tokens=* usebackq" %%g in (`svnlook log %svnlookparam%`) do (
       set bIsEmpty=false
    )
    if '%bIsEmpty%'=='true' goto ERROR_EMPTY
    
    echo Allowed. >&2
    
    goto :END
    
    
    :ERROR_EMPTY
    echo Empty log messages are not allowed. >&2
    goto ERROR_EXIT
    
    :ERROR_EXIT
    :: You may require to remove the /b below if your hook is called directly by subversion
    exit /b 1
    
    :END
    endlocal
    

提交回复
热议问题