From c81d4ab4a9101620e06cb401e7267789a6376d36 Mon Sep 17 00:00:00 2001 From: LeonB Date: Tue, 28 Aug 2012 10:57:23 +0200 Subject: [PATCH 1/3] Fixed some hardcoded paths New config option: git_hooks_path --- config/initializers/1_settings.rb | 4 ++++ lib/tasks/gitlab/backup.rake | 1 + lib/tasks/gitlab/status.rake | 2 +- lib/tasks/gitlab/write_hook.rake | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 8165d6c2..27c5bc22 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -66,6 +66,10 @@ class Settings < Settingslogic git_host['base_path'] || '/home/git/repositories/' end + def git_hooks_path + git_host['hooks_path'] || '/home/git/share/gitolite/hooks/' + end + def git_upload_pack if git_host['upload_pack'] != false true diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index 8e2fa2c0..4dffd1ad 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -145,6 +145,7 @@ namespace :gitlab do permission_commands = [ "sudo chmod -R g+rwX #{Gitlab.config.git_base_path}", "sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}", + "sudo chown gitlab:gitlab #{Gitlab.config.git_base_path}**/hooks/post-receive" ] permission_commands.each { |command| Kernel.system(command) } puts "[DONE]".green diff --git a/lib/tasks/gitlab/status.rake b/lib/tasks/gitlab/status.rake index 02d27d4b..91456189 100644 --- a/lib/tasks/gitlab/status.rake +++ b/lib/tasks/gitlab/status.rake @@ -56,7 +56,7 @@ namespace :gitlab do return end - gitolite_hooks_path = File.join("/home", Gitlab.config.ssh_user, "share", "gitolite", "hooks", "common") + gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") gitlab_hook_files = ['post-receive'] gitlab_hook_files.each do |file_name| dest = File.join(gitolite_hooks_path, file_name) diff --git a/lib/tasks/gitlab/write_hook.rake b/lib/tasks/gitlab/write_hook.rake index 098331b8..9ec9c838 100644 --- a/lib/tasks/gitlab/write_hook.rake +++ b/lib/tasks/gitlab/write_hook.rake @@ -2,7 +2,7 @@ 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") + gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") gitlab_hooks_path = Rails.root.join("lib", "hooks") gitlab_hook_files = ['post-receive'] From 05fa1f167c05c13b269b104de33dc7a38f34e347 Mon Sep 17 00:00:00 2001 From: LeonB Date: Tue, 28 Aug 2012 13:06:05 +0200 Subject: [PATCH 2/3] Added hooks_path option example --- config/gitlab.yml.example | 1 + 1 file changed, 1 insertion(+) diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index be36ee6d..d05cc1be 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -33,6 +33,7 @@ app: git_host: admin_uri: git@localhost:gitolite-admin base_path: /home/git/repositories/ + # hooks_path: /var/lib/gitolite/.gitolite/hooks/ # only needed when gitolite is not installed according the manual # host: localhost git_user: git upload_pack: true From ffdda12f663d6a634689f7c7b16560bcf792415e Mon Sep 17 00:00:00 2001 From: LeonB Date: Tue, 28 Aug 2012 14:18:49 +0200 Subject: [PATCH 3/3] Line not needed anymore --- lib/tasks/gitlab/backup.rake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index 4dffd1ad..04d240f6 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -144,8 +144,7 @@ namespace :gitlab do if Kernel.system("cd #{File.dirname(project.second)} > /dev/null 2>&1 && git clone --bare #{backup_path_repo}/#{project.first}.bundle #{project.first}.git > /dev/null 2>&1") permission_commands = [ "sudo chmod -R g+rwX #{Gitlab.config.git_base_path}", - "sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}", - "sudo chown gitlab:gitlab #{Gitlab.config.git_base_path}**/hooks/post-receive" + "sudo chown -R #{Gitlab.config.ssh_user}:#{Gitlab.config.ssh_user} #{Gitlab.config.git_base_path}" ] permission_commands.each { |command| Kernel.system(command) } puts "[DONE]".green