Forcing SVN Comments with TortoiseSVN

On July 22, 2008, in Subversion, by Anuj Gakhar

One of my earlier posts about forcing SVN comments talks about doing a pre-commit hook on SVN before every commit is made. The problem with that is, it needs to be done on the SVN server and not always you’ve got access to that. But as a developer you can force yourself to always comment before committing, as well. This one is particulary to do with TortoiseSVN as thats what I currently use at work.

The way it works is, once you have checked out a folder from the repository onto your local machine, you need to go to TortoiseSVN properties and add an inbuilt property to one or all your files. You can setup a property on one or more files so that it wont let you commit unless you write a minimum number of characters as my commit comments. The property is called tsvn:logminsize and it comes along with a set of other inbuilt properties. Simply right click anywhere in the checked out folder and go to TortoiseSVN Properties and add the property called tsvn:logminsize and give it a value of whatever you want. I gave it 10 (screenshot below).

TortoiseSVN logminsize

I added the property recursively so it applies to all my files. Once thats done, it wont even enable the “OK” button on the commit dialog box until you enter atleast 10 characters. Just a little reminder to myself that commenting is absolutely necessary.

I didnt realize this was possible until today and I am really liking it.

Tagged with:  

12 Responses to Forcing SVN Comments with TortoiseSVN

  1. Jeff says:

    Thanks a lot! I sometimes forget to include comments so this is very helpful

  2. Monty Menon says:


    you can enforce comment length validation on the server side as well by amending your own pre-commit hook script:

    instead of ‘findstr .’ use ‘findstr “…..”‘ where a ‘.’ is one char length. In other words the above will enforce a min of 5 chars in the comment.

  3. Anuj Gakhar says:

    @monty, thanks for letting me know. I will try that out. Cheers.

  4. Jon says:

    Does the comment requirement work for everyone using toroiseSVN or just our working copy? I’ve been trying to figure out how to force comments for specific directories within a repo…


  5. Anuj Gakhar says:

    @Jon, In this case, it would be just for yourself as you are doing it in your copy of TorToiseSVN. You can read my other post on this subject if you want to do it at the repository level.

  6. Anonymous says:

    Ok, but how do you set this server-side using Visual SVN Server so that all clients are required and set to use this property!

  7. Anuj Gakhar says:

    This solution is only for your local client. If you want to do a server-side, you would have to do a pre-commit hook as explained in my other post. VisualSVN server has an option to define hooks, if I am not mistaken.

  8. Hi, this property in fact doesn’t need to be set recursively. Thanks.

  9. cap says:

    Thanks Anuj,
    But if I want to force comment on specific folder by pre-commit hook (not all folder in repository on server), how to do it? Thanks

  10. Anuj Gakhar says:

    @cap, I have not tried this before but maybe someone else here has? you should look into the svn hooks docs.

  11. Bharat Sinha says:

    Hi Anuj,

    I dont see the apply property recursively checkbox enabled. Is any permission is needed for the same?

    Thanks, Bharat!

  12. Vinoth Kumar says:

    hi is it possible to force the field in the comment is mandatory like in the template comment Author={author} . we have to validate author field is filled or not then restrict commit.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2011 Anuj Gakhar