diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-06 17:39:31 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-06 17:39:31 +0200 |
commit | 9a407166fb5ec31e4bee70d165bb345ee9e06a6b (patch) | |
tree | 8ff4249b2978dca1fbe0fa45a4fdc185a48cb85b /lib/gitlab_projects.rb | |
parent | 96454ac5894b97bd9d94877524c77efa5d82fa14 (diff) | |
download | gitlab-shell-9a407166fb5ec31e4bee70d165bb345ee9e06a6b.tar.gz |
Update hook and support for protected branches
Diffstat (limited to 'lib/gitlab_projects.rb')
-rw-r--r-- | lib/gitlab_projects.rb | 12 |
1 files changed, 9 insertions, 3 deletions
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 |