summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandx <dmitriy.zaporozhets@gmail.com>2012-08-21 20:14:06 +0300
committerrandx <dmitriy.zaporozhets@gmail.com>2012-08-21 20:14:06 +0300
commitc625293b995cf21a1b551cecaac3cb742fcb2e66 (patch)
tree3680e0658fcaaee990867bdd690bc1f7c78d394a
parent2e7ca8c866179e78866cba1659dee45185911f5a (diff)
downloadgitlab-ce-c625293b995cf21a1b551cecaac3cb742fcb2e66.tar.gz
Handle post-receive files via gitolite, not gitlab
-rw-r--r--app/roles/repository.rb18
-rw-r--r--app/views/errors/gitolite.html.haml2
-rwxr-xr-xlib/hooks/post-receive (renamed from lib/post-receive-hook)0
-rw-r--r--lib/tasks/gitlab/setup.rake7
-rw-r--r--lib/tasks/gitlab/status.rake6
-rw-r--r--lib/tasks/gitlab/update_hooks.rake19
-rw-r--r--lib/tasks/gitlab/write_hook.rake23
7 files changed, 29 insertions, 46 deletions
diff --git a/app/roles/repository.rb b/app/roles/repository.rb
index 8d5b018de77..7f1d6f84549 100644
--- a/app/roles/repository.rb
+++ b/app/roles/repository.rb
@@ -30,26 +30,10 @@ module Repository
Commit.commits_between(repo, from, to)
end
- def write_hooks
- %w(post-receive).each do |hook|
- write_hook(hook, File.read(File.join(Rails.root, 'lib', "#{hook}-hook")))
- end
- end
-
def satellite
@satellite ||= Gitlab::Satellite.new(self)
end
- def write_hook(name, content)
- hook_file = File.join(path_to_repo, 'hooks', name)
-
- File.open(hook_file, 'w') do |f|
- f.write(content)
- end
-
- File.chmod(0775, hook_file)
- end
-
def has_post_receive_file?
hook_file = File.join(path_to_repo, 'hooks', 'post-receive')
File.exists?(hook_file)
@@ -73,8 +57,6 @@ module Repository
def update_repository
Gitlab::GitHost.system.update_project(path, self)
-
- write_hooks if File.exists?(path_to_repo)
end
def destroy_repository
diff --git a/app/views/errors/gitolite.html.haml b/app/views/errors/gitolite.html.haml
index 4788c2e5237..50268b1ad27 100644
--- a/app/views/errors/gitolite.html.haml
+++ b/app/views/errors/gitolite.html.haml
@@ -23,5 +23,3 @@
= preserve do
sudo chmod -R 770 /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
- sudo chown gitlab:gitlab /home/git/repositories/**/hooks/post-receive
-
diff --git a/lib/post-receive-hook b/lib/hooks/post-receive
index d38bd13e19d..d38bd13e19d 100755
--- a/lib/post-receive-hook
+++ b/lib/hooks/post-receive
diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake
index d60e73e9ac3..21ce5d7083c 100644
--- a/lib/tasks/gitlab/setup.rake
+++ b/lib/tasks/gitlab/setup.rake
@@ -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
diff --git a/lib/tasks/gitlab/status.rake b/lib/tasks/gitlab/status.rake
index bc4e86ea648..a16b1512dde 100644
--- a/lib/tasks/gitlab/status.rake
+++ b/lib/tasks/gitlab/status.rake
@@ -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
diff --git a/lib/tasks/gitlab/update_hooks.rake b/lib/tasks/gitlab/update_hooks.rake
deleted file mode 100644
index 44e1617e58f..00000000000
--- a/lib/tasks/gitlab/update_hooks.rake
+++ /dev/null
@@ -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
diff --git a/lib/tasks/gitlab/write_hook.rake b/lib/tasks/gitlab/write_hook.rake
new file mode 100644
index 00000000000..098331b8cd7
--- /dev/null
+++ b/lib/tasks/gitlab/write_hook.rake
@@ -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
+