rosa-build/lib/tasks/hook.rake

24 lines
790 B
Ruby
Raw Normal View History

2012-02-15 11:12:49 +00:00
namespace :hook do
desc "Inserting hook to all repos"
task :install => :environment do
origin_hook = File.join(::Rails.root.to_s, 'bin', "post-receive-hook#{ENV['RAILS_ENV'] == 'production' ? '_prod' : '_dev'}")
say "process.. #{origin_hook}"
count = 0
Project.all.each do |project|
hook_file = File.join(project.path, 'hooks', 'post-receive')
FileUtils.cp(origin_hook, hook_file)
count = count + 1
end
say "Done! Writing to #{count.to_s} repo(s)"
end
2012-02-15 11:23:49 +00:00
desc "remove git hook from all repos"
2012-02-15 11:12:49 +00:00
task :remove => :environment do
say "process.."
count = 0
Project.all.each { |project| FileUtils.rm_rf File.join(project.path, 'hooks', 'post-receive'); count = count + 1}
say "Done! Removing from #{count.to_s} repo(s)"
end
end