Subversion Commit Emails

posted Tuesday, 10 July 2007

If like me, you're accustomed to receiving email notifications when anyone makes a CVS commit in your projects, then you'd want the same when your project source code is stored in Subversion.

Thankfully Subversion makes it fairly easy via a couple of simple scripts.

In the root directory of your SVN project, there's a hooks directory. There you'll find a series of .tmpl files which are templates to use for each of the types of events that you can hook into (see hook scripts section in the Subversion book for more details). The one we're interested in is the post-commit event.

Make a copy of the post-commit.tmpl file called post-commit with sufficient execute rights for the svn users that will make the commits.

At the bottom of the script, you'll find these 2 lines:

commit-email.pl "$REPOS" "$REV" commit-watchers@example.org
log-commit.py --repository "$REPOS" --revision "$REV"

The first line refers to a perl script that exists in the tools/hook-scripts directory of your Subversion install (if you cannot find it then it can be obtained from http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/). Either copy that file to the hooks directory or edit the post-commit file so that it refers to the full path where commit-email.pl exists.

Then simply change the email address in the 3rd argument to the one you desire, and add a "--from" argument that specifies the email address that the notifications will appear to come from. Finally, comment out or remove the remaining line which isn't required.

Test that your post-commit script works by passing in the repository path and a recent revision number:

> ./post-commit /opt/repos 4

You should receive an email with details of the changes made in that revision.

Now just perform a commit in SVN and you should find that you now receive email notifications.

 

tags:  



Related Posts

Subversion Commit Emails

Tuesday, 10 July 2007 6:25 P GMT+01
If like me, you're accustomed to receiving email notifications when anyone makes a CVS commit in your projects, then you'd want the same when you're project source is stored in Subversion. Thankfully Subversion makes it fairly easy via a
tags:  

Better Subversion Notification Emails with SVN::Notify

Tuesday, 10 July 2007 6:25 P GMT+01
The SVN commit emails that I blogged about previously don't quite match the expectations I had, given the rich emails that CVSspam produces.The commit-email.pl script can certainly be hacked to your own preference but an alternative is to use SVN
tags: