<?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>Nuclear Rooster &#187; Capistrano</title>
	<atom:link href="http://dev.nuclearrooster.com/category/capistrano/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.nuclearrooster.com</link>
	<description></description>
	<lastBuildDate>Thu, 22 Dec 2011 17:43:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Overriding Capistrano</title>
		<link>http://dev.nuclearrooster.com/2007/09/07/overriding-capistrano/</link>
		<comments>http://dev.nuclearrooster.com/2007/09/07/overriding-capistrano/#comments</comments>
		<pubDate>Sat, 08 Sep 2007 00:41:57 +0000</pubDate>
		<dc:creator>nick.stielau</dc:creator>
				<category><![CDATA[Capistrano]]></category>
		<category><![CDATA[Ruby/Rails]]></category>

		<guid isPermaLink="false">http://dev.nuclearrooster.com/?p=15</guid>
		<description><![CDATA[Capistrano rocks for deployment, but I found myself wanting to override some spefic parts of the gem. I realize that I am a little late on the scene, as Capistrano 2.0 is out and about, but this solved some of my problems. Specifically, I wanted to customize the SVN checkout to use sudo, have sudo [...]]]></description>
			<content:encoded><![CDATA[<p>Capistrano rocks for deployment, but I found myself wanting to override some spefic parts of the gem.  I realize that I am a little late on the scene, as <a href="http://www.capify.org/">Capistrano 2.0</a> is out and about, but this solved some of my problems.</p>
<p>Specifically, I wanted to customize the SVN checkout to use sudo, have sudo default to specific user, and add a deployment message to the revisions log. This is all easy to do without editing the capistrano gem.  I looked around the gem source and found the code that I wanted to override, and then pulled it out and tweaked it.</p>
<p>In deploy.rb</p>
<pre class="brush: ruby; title: ; notranslate">
class ::Capistrano::SCM::Subversion
  alias_method :non_sudo_checkout, :checkout
  def checkout(actor)
    op = 'export'
    command = &quot;sudo -u USER #{svn} #{op} -q --config-dir /home/USER/.subversion -r#{configuration.revision} #{configuration.repository} #{actor.release_path} &amp;&amp;&quot;
   run_checkout(actor, command, &amp;svn_stream_handler(actor))
  end
end

class ::Capistrano::Actor
  alias_method :sudo_with_optional_user, :sudo
  def sudo(command, options={}, &amp;block)
    sudo_with_optional_user(command, {:as =&gt;; 'SUDO_USER'}.merge(options), &amp;block)
  end
end

class ::Capistrano::SCM::Base
  alias_method :logging_commands_without_message, :logging_commands
  def logging_commands(directory = nil)
    log = &quot;#{configuration.deploy_to}/revisions.log&quot;
    &quot;(test -e #{log} || (touch #{log} &amp;&amp; chmod 666 #{log})) &amp;&amp; &quot; +
    &quot;echo `date +\&quot;%Y-%m-%d %H:%M:%S\&quot;` $USER #{configuration.revision} #{directory} '#{configuration.message}' &amp;gt;&amp;gt; #{log};&quot;
  end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dev.nuclearrooster.com/2007/09/07/overriding-capistrano/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

