Wednesday, May 18, 2011

Usefulness of Commit Emails from Version Control Systems

A few days back I found this link on Hacker News about a blog post that talked about best practices for using version control systems. I also thought about something which I think ties in very well with his blog post. I recommend setting up commit emails for every commit done, whatever the VCS may be, Git, SVN, Perforce etc. Sometimes the usefulness of this system is not completely understood, so I will talk about here. My notes on this are based on my experience with using commit emails from SVN (set up with mailer.py and svnspam), but I think it should be applicable to any version control system.

Code Review Tool: Ideally all code that is checked-in should be code reviewed beforehand. Sometimes it is not possible to do so, maybe the check-in is of two lines or there are time constraints. Then you can just say "check it in, I will review the commit email". And then based on what you see in that email you can recommend changes. Now this is not as good as code review before check-in but this still helps. This way a lead engineer can also recommend further changes in code if necessary.

Enforce Standards: Pre-commit hooks can be used to ensure agreed upon formatting, but sometimes coding conventions are harder to enforce. Having commit emails ensures that a lead engineer can request more changes in code to ensure code confirms to a standard and is consistent with existing conventions.

Watch Modules:
With email filters and module names in commit email subjects, it is very easy to setup filters to track specific modules. In a large company with a number of modules in development this makes it easy watch specific modules, even ones that are being developed by other teams.

Increased Visibility: Anyone in the company can ask to be included in this mailing list. This is especially useful for managers who want to track progress on various modules and don't want to install version control tools.

Handy record of releases: Many times I have had to look up a release version I created months back. With the commit emails I can just search my inbox for the tag and thus get all the info I need. I don't have to use Tortoise Repo-browser to look up the tag.

Merge requests:
Commit emails can also be used by the team to forward specific changes to one another, in order to be merged in another modules. This is very useful for small changes that need to be merged, and an email will be sufficient for that.

I am sure there are other uses of this kind of system, do you have this setup where you work? Have you found it useful in other ways? Let me know.