rosa-build/lib/tasks/hook.rake

36 lines
1.1 KiB
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
hook = "/home/#{APP_CONFIG['shell_user']}/gitlab-shell/hooks/post-receive"
2012-02-15 13:06:25 +00:00
say "Install process.."
count, projects = 0, Project.scoped
projects = projects.where(:id => ENV['PROJECT_ID']) if ENV['PROJECT_ID']
projects.each do |project|
next unless Dir.exist? project.path
2012-02-15 11:12:49 +00:00
hook_file = File.join(project.path, 'hooks', 'post-receive')
FileUtils.rm_rf hook_file
2012-04-02 20:30:14 +01:00
begin
FileUtils.ln_sf(hook, hook_file)
2012-04-02 20:30:14 +01:00
count = count + 1
rescue Exception => e
say "----\nCatching exception with project #{project.id}"
say e.message
say '----'
end
2012-02-15 11:12:49 +00:00
end
2012-02-15 13:06:25 +00:00
say "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, projects = 0, Project.scoped
projects = projects.where(:id => ENV['PROJECT_ID']) if ENV['PROJECT_ID']
projects.each do |project|
FileUtils.rm_rf File.join(project.path, 'hooks', 'post-receive')
count = count + 1
end
2012-02-15 11:12:49 +00:00
say "Done! Removing from #{count.to_s} repo(s)"
end
end