Get Subversion Updates via Email

Posted on in Programming

Coffee Cup with @Sometimes it seems like a great idea to receive updates whenever someone commits something to your Subversion repository, right? This has definitely seemed like a good idea to me, but it's only nice if you work in a small shop with only a few developers. Too many developers make this solution more of a headache than anything else. But, if you really like to keep up with what's going on and you are undaunted by the influx of email, the setup isn't difficult at all.

  1. Install the SVN::Notify Perl module.
    The first thing you should do is install SVN::Notify. Many ports collections include this module (MacPorts for example), so your installation may be as simple as running the appropriate install command (sudo port install p5-svn-notify, perhaps?). If your ports collection doesn't include this module, installation should be as simple as

    $ perl Makefile.PL
    $ make
    $ sudo make install
    

    Once you have installed the module, you'll need to know the location of svnnotify. For the sake of this article, we'll assume that it is /usr/bin/svnnotify.

  2. Copy post-commit.tmpl to post-commit.
    In the top level directory of your Subversion repository, you should see a directory called hooks. Change into that directory and copy post-commit.tmpl to post-commit, and make sure this script is executable. This is where the magic happens.

  3. Update post-commit.
    The post-commit script includes some commands by default. For example, mine contained the following lines

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

    Those lines are not what we want to do, so comment them out (using #) and add the following

    REPOS="$1"
    REV="$2"
    /usr/bin/svnnotify --repos-path "$1" --revision "$2" --to svn@slaptijack.com --handler HTML::ColorDiff --svnlook /usr/bin/svnlook --with-diff
    

    Remember to replace 'svn@slaptijack.com' with your own email address.

It really is that easy. After this, you should start getting nice color diffs emailed to the email address indicated.

Update: Corey Gilmore apparently had the same brainwave about a week before I did: Subversion: Emailing users on commit.

My Bookshelf

Reading Now

Other Stuff