SVN hooks for Windows

后端 未结 9 939
温柔的废话
温柔的废话 2021-01-30 00:18

I did a little googling and found that there isn\'t really a resource of SVN hooks for Windows. So I figured I\'d start a wiki here to centralize it.

If you contribute,

9条回答
  •  一整个雨季
    2021-01-30 00:48

    Checks for common "lazy" commit messages

    1. The name of the hook = pre-commit
    2. What the script does = Check for blank line or '.' line. Also check a file of words not allowed to be the sole comment.

    The actual script

    rem Make sure that the log message contains some text.
    set REPOS=%1
    set TXN=%2
    
    "C:\Program Files\Subversion\bin\SVNlook.exe" log -t %TXN% %REPOS% | FindStr [a-zA-Z0-9]
    IF %ERRORLEVEL% EQU 0 GOTO OK
    echo Your commit has been blocked because you didn't provide a log message  1>&2
    echo Please write a log message describing the purpose of your changes and 1>&2
    echo then try committing again. -- Thank you 1>&2 
    exit 1
    
    :OK
    rem Check if comment is in list of reserved words to not be used..
    
    "C:\Program Files\Subversion\bin\SVNlook.exe" log -t %TXN% %REPOS% >comment
    setlocal enabledelayedexpansion
    Set SEPARATOR=
    set COMMENT=
    for /f "delims=" %%a in (comment) do (  
        set currentline=%%a
        set COMMENT=!COMMENT!%SEPARATOR%!currentline!
    )
    
    FIND "%COMMENT%" "C:\Program Files\Subversion\excludedwords.txt">Null
    If %ERRORLEVEL% EQU 1 goto OK2
    
    :Fail
    echo Your commit has been blocked because the single word comment you provided is not allowed 1>&2
    echo Line is -%COMMENT%- 1>&2
    echo Please write a proper log message describing the purpose of your changes and 1>&2
    echo then try committing again. -- Thank you 1>&2 
    exit 1
    
    
    :OK2
    rem Check that the author of this commit has the rights to perform
    rem the commit on the files and directories being modified.
    rem commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1
    
    rem All checks passed, so allow the commit.
    exit 0
    

    Sample Excluded words file: Updated updated updated. Updated. Fix fix Fix. fix. .. . ... . . . . sorted sorted. Sorted Sorted.

    etc etc etc etc

提交回复
热议问题