<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hungry Machine &#187; svn</title>
	<atom:link href="http://blog.hungrymachine.com/tag/svn/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hungrymachine.com</link>
	<description>The guys behind LivingSocial</description>
	<lastBuildDate>Sun, 25 Oct 2009 15:08:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pretty SVN commit emails</title>
		<link>http://blog.hungrymachine.com/2007/11/05/pretty-svn-commit-emails/</link>
		<comments>http://blog.hungrymachine.com/2007/11/05/pretty-svn-commit-emails/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 18:51:00 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">blog.hungrymachine.com/2008/06/05/pretty-svn-commit-emails</guid>
		<description><![CDATA[
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&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float:left;padding-right:5px" src="http://blog.hungrymachine.com/assets/2007/11/5/Picture_10_1.png"></p>
<p>So i know it may be old school, but I like getting svn commit messages, especially when working on a small team.  I found <a href="http://elliotth.blogspot.com">ElliotH&#8217;s</a> post about <a href="http://elliotth.blogspot.com/2005/02/better-subversion-post-commit-hook.html">A better subversion post-commit hook than commit-email.pl</a>, but it wasnt entirely working. </p>
<p>Most of the credit goes to him, I just fixed the colorization.  </p>
<p>[UPDATED]: for some reason, new lines werent looking good in all emails</p>
<div class="CodeRay">
<div class="code">
<pre><span style="color:#888">#!/usr/bin/ruby -w</span>

<span style="color:#888"># A Subversion post-commit hook. Edit the configurable stuff below, and</span>
<span style="color:#888"># copy into your repository's hooks/ directory as &quot;post-commit&quot;. Don't</span>
<span style="color:#888"># forget to &quot;chmod a+x post-commit&quot;.</span>

<span style="color:#888"># ------------------------------------------------------------------------</span>

<span style="color:#888"># You *will* need to change these.</span>

address=<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">FOO@SOME_DOMAIN.com</span><span style="color:#710">&quot;</span></span>
sendmail=<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">/usr/sbin/sendmail</span><span style="color:#710">&quot;</span></span>
svnlook=<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">/usr/bin/svnlook</span><span style="color:#710">&quot;</span></span>

<span style="color:#888"># ------------------------------------------------------------------------</span>

require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">cgi</span><span style="color:#710">'</span></span>

<span style="color:#888"># Subversion's commit-email.pl suggests that svnlook might create files.</span>
<span style="color:#036; font-weight:bold">Dir</span>.chdir(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">/tmp</span><span style="color:#710">&quot;</span></span>)

<span style="color:#888"># What revision in what repository?</span>
repo = <span style="color:#038; font-weight:bold">ARGV</span>.shift()
rev = <span style="color:#038; font-weight:bold">ARGV</span>.shift()

<span style="color:#888"># Get the overview information.</span>
info=<span style="background-color:#f0fff0"><span style="color:#161">`</span><span style="background-color:#f0fff0"><span style="color:#161">#{</span>svnlook<span style="color:#161">}</span></span><span style="color:#2B2"> info </span><span style="background-color:#f0fff0"><span style="color:#161">#{</span>repo<span style="color:#161">}</span></span><span style="color:#2B2"> -r </span><span style="background-color:#f0fff0"><span style="color:#161">#{</span>rev<span style="color:#161">}</span></span><span style="color:#161">`</span></span>
info_lines=info.split(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>)
author=info_lines.shift
date=info_lines.shift
info_lines.shift
comment=info_lines

<span style="color:#888"># Output the overview.</span>
body = <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">&lt;p&gt;&lt;b&gt;</span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>author<span style="color:#710">}</span></span><span style="color:#D20">&lt;/b&gt; </span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>date<span style="color:#710">}</span></span><span style="color:#D20">&lt;/p&gt;</span><span style="color:#710">&quot;</span></span>
body &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">&lt;p&gt;</span><span style="color:#710">&quot;</span></span>
comment.each { |line|  body &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="background-color:#fff0f0"><span style="color:#710">#{</span><span style="color:#036; font-weight:bold">CGI</span>.escapeHTML(line)<span style="color:#710">}</span></span><span style="color:#D20">&lt;br/&gt;</span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span> }
body &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">&lt;/p&gt;</span><span style="color:#710">&quot;</span></span>
body &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">&lt;hr noshade&gt;</span><span style="color:#710">&quot;</span></span>

<span style="color:#888"># Get and output the patch.</span>
changes=<span style="background-color:#f0fff0"><span style="color:#161">`</span><span style="background-color:#f0fff0"><span style="color:#161">#{</span>svnlook<span style="color:#161">}</span></span><span style="color:#2B2"> diff </span><span style="background-color:#f0fff0"><span style="color:#161">#{</span>repo<span style="color:#161">}</span></span><span style="color:#2B2"> -r </span><span style="background-color:#f0fff0"><span style="color:#161">#{</span>rev<span style="color:#161">}</span></span><span style="color:#161">`</span></span>
body &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">&lt;pre&gt;</span><span style="color:#710">&quot;</span></span>
changes.each <span style="color:#080; font-weight:bold">do</span> |top_line|
  top_line.split(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>).each <span style="color:#080; font-weight:bold">do</span> |line|
    color = <span style="color:#080; font-weight:bold">case</span>
      <span style="color:#080; font-weight:bold">when</span> line =~ <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">^Modified: </span><span style="color:#404">/</span></span> || line =~ <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">^=+$</span><span style="color:#404">/</span></span> || line =~ <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">^@@ </span><span style="color:#404">/</span></span>: <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">gray</span><span style="color:#710">&quot;</span></span>
      <span style="color:#080; font-weight:bold">when</span> line =~ <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">^-</span><span style="color:#404">/</span></span>: <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">red</span><span style="color:#710">&quot;</span></span>
      <span style="color:#080; font-weight:bold">when</span> line =~ <span style="background-color:#fff0ff"><span style="color:#404">/</span><span style="color:#808">^</span><span style="color:#04D">\+</span><span style="color:#404">/</span></span>: <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">blue</span><span style="color:#710">&quot;</span></span>
      <span style="color:#080; font-weight:bold">else</span> <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">black</span><span style="color:#710">&quot;</span></span>
    <span style="color:#080; font-weight:bold">end</span>
    body &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">%Q{</span><span style="color:#D20">&lt;font style=&quot;color:</span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>color<span style="color:#710">}</span></span><span style="color:#D20">&quot;&gt;</span><span style="background-color:#fff0f0"><span style="color:#710">#{</span><span style="color:#036; font-weight:bold">CGI</span>.escapeHTML(line)<span style="color:#710">}</span></span><span style="color:#D20">&lt;/font&gt;&lt;br/&gt;</span><span style="color:#04D">\n</span><span style="color:#710">}</span></span>
 <span style="color:#080; font-weight:bold">end</span>
<span style="color:#080; font-weight:bold">end</span>
body &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">&lt;/pre&gt;</span><span style="color:#710">&quot;</span></span>

<span style="color:#888"># Write the header.</span>
header = <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#710">&quot;</span></span>
header &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">To: </span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>address<span style="color:#710">}</span></span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>
header &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">From: </span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>address<span style="color:#710">}</span></span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>
header &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">Subject: [SVN] </span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>repo<span style="color:#710">}</span></span><span style="color:#D20"> revision </span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>rev<span style="color:#710">}</span></span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>
header &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">Reply-to: </span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>address<span style="color:#710">}</span></span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>
header &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">MIME-Version: 1.0</span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>
header &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">Content-Type: text/html; charset=UTF-8</span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>
header &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">Content-Transfer-Encoding: 8bit</span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>
header &lt;&lt; <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>

<span style="color:#888"># Send the mail.</span>
<span style="color:#080; font-weight:bold">begin</span>
    fd = open(<span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">|</span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>sendmail<span style="color:#710">}</span></span><span style="color:#D20"> </span><span style="background-color:#fff0f0"><span style="color:#710">#{</span>address<span style="color:#710">}</span></span><span style="color:#710">&quot;</span></span>, <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#D20">w</span><span style="color:#710">&quot;</span></span>)
    fd.print(header)
    fd.print(body)
<span style="color:#080; font-weight:bold">rescue</span>
    exit(<span style="color:#00D; font-weight:bold">1</span>)
<span style="color:#080; font-weight:bold">end</span>
fd.close

<span style="color:#888"># We're done.</span>
exit(<span style="color:#00D; font-weight:bold">0</span>)</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.hungrymachine.com/2007/11/05/pretty-svn-commit-emails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
