How can I prevent Subversion commits without comments?

后端 未结 6 1279
眼角桃花
眼角桃花 2020-12-04 14:08

Does anybody know how to prevent commits to a Subversion code repository when there is no commit comment entered?

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 14:38

    Here is a pre-commit hook with @miku's detailed error message for Linux:

    #!/bin/sh
    
    REPOS="$1"
    TXN="$2"
    
    SVNLOOK=/usr/bin/svnlook
    $SVNLOOK log -t "$TXN" "$REPOS" | \
       grep "[a-zA-Z0-9]" > /dev/null
    
    GREP_STATUS=$?
    if [ $GREP_STATUS -ne 0 ]
    then
        echo "Your commit has been blocked because you didn't give any 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
    fi
    exit 0
    

提交回复
热议问题