I use Subversion (SVN) for my source control and I access SVN through TortoiseSVN so that its integrated into the Windows shell. The past few companies I've worked at have all utilized SVN in one way or another, but we've always had a problem with developers submitting code without attaching a message to the commit.
Why does this matter? If you, as a developer, check in 20 files that are related to project trunk X, without a message, how am I suppossed to know why you checked those into the repository? Did you fix a bug? Did you implement a new feature? Did you complete a task? Did you add a new project to the system? What did you do? Thats the problem if you do not provide a message for each commit, others have no idea of knowing what you did.
By not providing the message we're not keeping track of what we did and why we did it. This comes heavily into play when you need to revert back to a certain revision, but you're not sure which revision to go back to. The only thing you remember is "I know it was when we implemented feature 'ABC' into the system." If I provided a comment, I could see in the Tortoise Log that on MM/DD/YYYY at XX:XX time developer "Bob" implemented the feature. Knowing that, I could find the version number and revert back to that revision. Without this information I might spend HOURS UPON HOURS searching through lines of code looking for a key piece that helps me decide if this is the version I want. This could have been avoided if a simple message was provided.
HOWTO: Requiring Messages
By default SVN does not require a message when committing. You can tap into the hooks of SVN and provide some custom code to force your developers to provide a message. The script to do this is below. Note: I cannot take credit for creating this script, as it was found on the net and I dont have the source. So, if you wrote this script, please let me know and I'll add your name here as the author. :)
Steps:
- Create Script
- Save as pre-commit.bat
- Drop it into the hooks directory of your repository.
- DONE
The Script (also provided at the bottom of this post as a download)
@echo off
::
:: Stops commits that have empty log messages.
::
setlocal
set "REPOS=%~1"
set "TXN=%~2"
set "SVNLOOK=c:\progra~1\subversion\bin\svnlook.exe"
:: Make sure that the log message contains some text.
for /f "tokens=*" %%i in ('%SVNLOOK% log -t "%TXN%" "%REPOS%"') do set "LOGMSG=%%i"
if not "%LOGMSG%"=="" exit 0
echo. 1>&2
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
Please note: This assumes that you have Subversion installed in the C:\Program Files\
Save this script as "pre-commit.bat".
Now drop this into your hooks directory of your actual repository. SVN will now execute this batch file each time a commit is taking place. It will check that a message exists. If one does not, it will throw an error message that is highlighted in dark red (above, in the script).
If you are using TortoiseSVN, this is what you will see:

Thats it. Now users cannot commit without a message. :)
Good Message Recommendations
Even if messages are required it still does not prevent a user from typing some garbage into the screen. Here's what I recommened to my team...
SVN Messages should contain:
- What you did. Give a quick explanation "altered file processing routine" or "created new project library"
- Why you did it. This could be as simple as stating "Fixed Bug 456" or "added new library to handle file conversions."
Example messages:
"Fixed bug 456 by altering file processing routine"
"Added new library to project XYZ to handle file conversions".
There are also many other plug-ins that have been built for TortoiseSVN and SVN in general. Just search for them and you should be able to find something that matches your bug tracking system (such as Gemini).
Conclusion
Forcing the developers to provide a message has enabled the team to communicate better. No longer are members constantly asking the question of "when was this fix applied?" or "What version did this happen in?" The messages make the respository easier to manage and a respository thats easy to manage means we have a healthier code base. :)
Download
pre-commit.zip (.48 KB)