From 9a407166fb5ec31e4bee70d165bb345ee9e06a6b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 6 Feb 2013 17:39:31 +0200 Subject: Update hook and support for protected branches --- lib/gitlab_projects.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/gitlab_projects.rb') diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb index 33b1c21..9afcb48 100644 --- a/lib/gitlab_projects.rb +++ b/lib/gitlab_projects.rb @@ -10,7 +10,6 @@ class GitlabProjects @project_name = ARGV.shift @repos_path = GitlabConfig.new.repos_path @full_path = File.join(@repos_path, @project_name) - @hook_path = File.join(ROOT_PATH, 'hooks', 'post-receive') end def exec @@ -27,17 +26,24 @@ class GitlabProjects def add_project FileUtils.mkdir_p(full_path, mode: 0770) - cmd = "cd #{full_path} && git init --bare && ln -s #{@hook_path} #{full_path}/hooks/post-receive" + cmd = "cd #{full_path} && git init --bare && #{create_hooks_cmd}" system(cmd) end + def create_hooks_cmd + pr_hook_path = File.join(ROOT_PATH, 'hooks', 'post-receive') + up_hook_path = File.join(ROOT_PATH, 'hooks', 'update') + + "ln -s #{pr_hook_path} #{full_path}/hooks/post-receive && ln -s #{up_hook_path} #{full_path}/hooks/update" + end + def rm_project FileUtils.rm_rf(full_path) end def import_project dir = @project_name.match(/[a-zA-Z\.\_\-]+\.git$/).to_s - cmd = "cd #{@repos_path} && git clone --bare #{@project_name} #{dir} && ln -s #{@hook_path} #{@repos_path}/#{dir}/hooks/post-receive" + cmd = "cd #{@repos_path} && git clone --bare #{@project_name} #{dir} && #{create_hooks_cmd}" system(cmd) end end -- cgit v1.2.1