Over a million developers have joined DZone.

Capistrano : Apply Local Patches When Deploying From An External Source Code Repository

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 
in your local directory, and apply them before restarting your app. task :after_setup do patches_setup end task :after_update_code do send_and_apply_patches end task :patches_setup do run "mkdir -p #{deploy_to}/#{shared_dir}/patches" end task :send_and_apply_patches do Dir[File.join(File.dirname(__FILE__), '../patches/*.diff')].sort.each do |patch| puts "sending #{File.basename(patch)}" put(File.read(patch), "#{deploy_to}/#{shared_dir}/patches/#{File.basename(patch)}", :mode => 0777) puts "applying #{File.basename(patch)}" run "cd #{release_path}; patch -p0 < #{deploy_to}/#{shared_dir}/patches/#{File.basename(patch)}" end end

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}