<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: diff code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 08 Aug 2008 02:00:09 GMT</pubDate>
    <description>DZone Snippets: diff code</description>
    <item>
      <title>Capistrano : apply local patches when deploying from an external source code repository</title>
      <link>http://snippets.dzone.com/posts/show/3147</link>
      <description>I've submitted patches to a couple rails apps, and want to run off of their SCM's trunk code, but with my local patches applied. These Capistrano tasks will take any files matching &lt;pre&gt;patches/*.diff&lt;/pre&gt; in your local directory, and apply them before restarting your app.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;task :after_setup do&lt;br /&gt;  patches_setup&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;task :after_update_code do&lt;br /&gt;  send_and_apply_patches&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;task :patches_setup do&lt;br /&gt;  run "mkdir -p #{deploy_to}/#{shared_dir}/patches" &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;task :send_and_apply_patches do&lt;br /&gt;  Dir[File.join(File.dirname(__FILE__), '../patches/*.diff')].sort.each do |patch|&lt;br /&gt;    puts "sending #{File.basename(patch)}"&lt;br /&gt;    put(File.read(patch),&lt;br /&gt;       "#{deploy_to}/#{shared_dir}/patches/#{File.basename(patch)}",&lt;br /&gt;       :mode =&gt; 0777)&lt;br /&gt;    puts "applying #{File.basename(patch)}"&lt;br /&gt;    run "cd #{release_path}; patch -p0 &lt; #{deploy_to}/#{shared_dir}/patches/#{File.basename(patch)}"&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 13 Dec 2006 20:51:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3147</guid>
      <author>jnewland (Jesse Newland)</author>
    </item>
  </channel>
</rss>
