So i know it may be old school, but I like getting svn commit messages, especially when working on a small team. I found ElliotH's post about A better subversion post-commit hook than commit-email.pl, but it wasnt entirely working.
Most of the credit goes to him, I just fixed the colorization.
[UPDATED]: for some reason, new lines werent looking good in all emails#!/usr/bin/ruby -w # A Subversion post-commit hook. Edit the configurable stuff below, and # copy into your repository's hooks/ directory as "post-commit". Don't # forget to "chmod a+x post-commit". # ------------------------------------------------------------------------ # You *will* need to change these. address="FOO@SOME_DOMAIN.com" sendmail="/usr/sbin/sendmail" svnlook="/usr/bin/svnlook" # ------------------------------------------------------------------------ require 'cgi' # Subversion's commit-email.pl suggests that svnlook might create files. Dir.chdir("/tmp") # What revision in what repository? repo = ARGV.shift() rev = ARGV.shift() # Get the overview information. info=`#{svnlook} info #{repo} -r #{rev}` info_lines=info.split("\n") author=info_lines.shift date=info_lines.shift info_lines.shift comment=info_lines # Output the overview. body = "<p><b>#{author}</b> #{date}</p>" body << "<p>" comment.each { |line| body << "#{CGI.escapeHTML(line)}<br/>\n" } body << "</p>" body << "<hr noshade>" # Get and output the patch. changes=`#{svnlook} diff #{repo} -r #{rev}` body << "<pre>" changes.each do |top_line| top_line.split("\n").each do |line| color = case when line =~ /^Modified: / || line =~ /^=+$/ || line =~ /^@@ /: "gray" when line =~ /^-/: "red" when line =~ /^\+/: "blue" else "black" end body << %Q{<font style="color:#{color}">#{CGI.escapeHTML(line)}</font><br/>\n} end end body << "</pre>" # Write the header. header = "" header << "To: #{address}\n" header << "From: #{address}\n" header << "Subject: [SVN] #{repo} revision #{rev}\n" header << "Reply-to: #{address}\n" header << "MIME-Version: 1.0\n" header << "Content-Type: text/html; charset=UTF-8\n" header << "Content-Transfer-Encoding: 8bit\n" header << "\n" # Send the mail. begin fd = open("|#{sendmail} #{address}", "w") fd.print(header) fd.print(body) rescue exit(1) end fd.close # We're done. exit(0)
