How to require commit messages in VisualSVN server?

后端 未结 10 1915
故里飘歌
故里飘歌 2020-12-07 12:00

We\'ve got VisualSVN Server set up as our Subversion server on Windows, and we use Ankhsvn + TortoiseSVN as clients on our workstations.

How can you configure the se

相关标签:
10条回答
  • 2020-12-07 12:17

    Note: This Only Applies To TortoiseSVN

    Simply right-click the top level of your Repository. In the context-menu select TortoiseSVN, then Properties, to see this dialog:

    enter image description here

    Click the New button near the bottom right, and select Log Sizes. Enter the number of characters you want to require for Commit and Lock (10 in example below).

    enter image description here

    Do a Commit from the top Level directory you just modified. Now your repository requires all users to Comment before Committing changes.

    0 讨论(0)
  • 2020-12-07 12:21

    Use this pre-commit hook on Windows. It's written in Windows Batch and uses grep command-line utility to check the commit length.

    svnlook log -t "%2" "%1" | c:\tools\grep -c "[a-zA-z0-9]" > nul
    if %ERRORLEVEL% NEQ 1 exit 0
    
    echo Please enter a check-in comment 1>&2
    exit 1
    

    Remember that you'll need a copy of grep, I recommend the gnu tools version.

    0 讨论(0)
  • 2020-12-07 12:23

    VisualSVN Server 3.9 provides the VisualSVNServerHooks.exe check-logmessage pre-commit hook that helps you reject commits with empty or short log messages. See the article KB140: Validating commit log messages in VisualSVN Server for instructions.

    Besides the built-in VisualSVNServerHooks.exe, VisualSVN Server and SVN in general uses a number of hooks to accomplish tasks like this.

    • start-commit — run before commit transaction begins, can be used to do special permission checking
    • pre-commit — run at the end of the transaction, but before commit. Often used to validate things such as a non zero length log message.
    • post-commit — runs after the transaction has been committed. Can be used for sending emails, or backing up repository.
    • pre-revprop-change — runs before a revision property change. Can be used to check permissions.
    • post-revprop-change — runs after a revision property change. Can be used to email or backup these changes.

    You need to use the pre-commit hook. You can write it yourself in just about any language your platform supports, but there are a number of scripts on the web. Googling "svn precommit hook to require comment" I found a couple that looked like they would fit the bill:

    • Perl Script
    • Python Script
    0 讨论(0)
  • 2020-12-07 12:26

    The technical answers to your question have already been given. I'd like to add the social answer, which is: "By establishing commit message standards with your team and getting them to agree (or accept) reasons why one would need expressive commit messages"

    I've seen so many commit messages that said "patch", "typo", "fix" or similar that I've lost count.

    Really - make it clear to everybody why you'd need them.

    Examples for reasons are:

    • Generated Changenotes (well - this'd actually make a nice automatic tool to enforce good messages if I know that they will be (with my name) publically visible - if only for the team)
    • License issues: You might need to know the origin of code later, e.g. should you want to change the license to your code (Some organizations even have standards for commit message formatting - well, you could automate the checking for this, but you'd not necessarily get good commit messages with this)
    • Interoperability with other tools, e.g. bugtrackers/issue management systems that interface with your version control and extract information from the commit messages.

    Hope that helps, additionally to the technical answers about precommit hooks.

    0 讨论(0)
提交回复
热议问题