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
patches/*.diff
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