Ruby Script for SVN commit notification with log message, list of updated files and readable colored SVN Diff

Published on Author Akhil Bansal9 Comments

Some days ago I wrote a post about “SVN commit notification” which uses a perl script for sending commit notification with svn diff by mail. In this mail you can find svn diff from the last committed revision. I used to love this mail, soon I realized that it is a bit ugly and difficult to read. Also there were some important information missing. Like the name of user committing the code, the log message etc…

And then I started writing my own ruby script for same purpose but with some addition and modification. Commit Notification Script is that script, you can download and configure it with your SVN post commit hook as follows.

Add following line at the bottom of your post-commit file:

/usr/bin/ruby /var/www/repositories/project/hooks/commit-email.rb "$1"  "$2"

* Please remember to change the path of you commit-email ruby script.

Now open commit-email ruby file and modify the following section according to your requirement:

# You can edit below

# Subject prefix
sub = "[[email protected]]"  # A project 'test_project' is maitained at vinsol

#list of users who will recieve commit notification
recipients = ["[email protected]", "[email protected]"]

# email which will appear in from email field
from_user = "[email protected]"

# your smtp settings here
ActionMailer::Base.smtp_settings = { :address => 'localhost', :port => 25, :domain => 'domain.com'}

# Do not edit below this line

You are done with that, now onwards whenever someone commits the code, you’ll get the commit notification mail like:

Commit Email Preview

9 Responses to Ruby Script for SVN commit notification with log message, list of updated files and readable colored SVN Diff

  1. Can you upload or pastie this somewhere else? Your blog isn’t letting me download it – I get a 500 error from your download script.

  2. This is a great base for what I’ve wanted as a post-commit script.

    It would be nice if there were options for ViewVC-type links, and other things.

    I’ve added that stuff hard-coded to my situation, but I may go back through and make them more generic. Are those changes something you be interested in seeing back, or are you at the “wash my hands of it” stage?

  3. Just in case someone using this isn’t familiar with ActionMailer, you can configure it to authenticate against a mail server like so:

    ActionMailer::Base.smtp_settings = {
    :address => “mail server address”,
    :port => 25,
    :domain => “mail domain”,
    :authentication => :login,
    :user_name => “mail account”,
    :password => “password”
    }

  4. We’ve found this script incredibly helpful – many thanks! But we’ve just switched to git, and miss it terribly… has anyone ported this to git?

  5. Thanks for the handy script. Our organization finally gave me the go-ahead to upgrade everything to SVN and I am wanting to learn Ruby to support what I do (Configuration Management). I appreciate the post!

Leave a Reply

Your email address will not be published. Required fields are marked *