namespace :branches => :environment do updates = [] Branch.find_all.each do |branch| name = "update:%s" % branch.name # Create the checkout task; the name is the file # created by performing the checkout. file branch.path do puts "Checking out %s" % branch.desc begin
branch.checkout
rescue => detail
$stderr.puts detail
end
end
# And create a task for actually updating the branch
task name => file.branch do
puts "Updating %s" % branch.desc
begin
branch.update_repository
rescue => detail
$stderr.puts detail
end
end
updates << name
end
desc "Update all branches"
task :update => updates
end