Handle post-receive files via gitolite, not gitlab

This commit is contained in:
randx 2012-08-21 20:14:06 +03:00
parent 2e7ca8c866
commit c625293b99
7 changed files with 29 additions and 46 deletions

View file

@ -1,7 +1,12 @@
namespace :gitlab do
namespace :app do
desc "GITLAB | Setup production application"
task :setup => ['db:setup', 'db:seed_fu', 'gitlab:app:enable_automerge']
task :setup => [
'db:setup',
'db:seed_fu',
'gitlab:gitolite:write_hooks',
'gitlab:app:enable_automerge'
]
end
end

View file

@ -67,12 +67,6 @@ namespace :gitlab do
next
end
unless File.owned?(hook_file)
puts "post-receive file is not owner by gitlab".red
next
end
puts "post-reveice file ok".green
end
end

View file

@ -1,19 +0,0 @@
namespace :gitlab do
namespace :gitolite do
desc "GITLAB | Rewrite hooks for repos"
task :update_hooks => :environment do
puts "Starting Projects"
Project.find_each(:batch_size => 100) do |project|
begin
if project.commit
project.write_hooks
print ".".green
end
rescue Exception => e
print e.message.red
end
end
puts "\nDone with projects"
end
end
end

View file

@ -0,0 +1,23 @@
namespace :gitlab do
namespace :gitolite do
desc "GITLAB | Write GITLAB hook for gitolite"
task :write_hooks => :environment do
gitolite_hooks_path = File.join("/home", Gitlab.config.ssh_user, "share", "gitolite", "hooks", "common")
gitlab_hooks_path = Rails.root.join("lib", "hooks")
gitlab_hook_files = ['post-receive']
gitlab_hook_files.each do |file_name|
source = File.join(gitlab_hooks_path, file_name)
dest = File.join(gitolite_hooks_path, file_name)
puts "sudo -u root cp #{source} #{dest}".yellow
`sudo -u root cp #{source} #{dest}`
puts "sudo -u root chown git:git #{dest}".yellow
`sudo -u root chown git:git #{dest}`
end
end
end
end