diff options
-rw-r--r-- | hooks/post-receive | 12 | ||||
-rw-r--r-- | lib/gitlab_projects.rb | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/hooks/post-receive b/hooks/post-receive new file mode 100644 index 0000000..6944d3e --- /dev/null +++ b/hooks/post-receive @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Version 4.1 +# This file was placed here by GitLab. It makes sure that your pushed commits +# will be processed properly. + +while read oldrev newrev ref +do + # For every branch or tag that was pushed, create a Resque job in redis. + repo_path=`pwd` + env -i redis-cli rpush "resque:gitlab:queue:post_receive" "{\"class\":\"PostReceive\",\"args\":[\"$repo_path\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]}" > /dev/null 2>&1 +done diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb index 89fb603..ae8cb2d 100644 --- a/lib/gitlab_projects.rb +++ b/lib/gitlab_projects.rb @@ -10,6 +10,7 @@ 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 @@ -24,8 +25,8 @@ class GitlabProjects protected def add_project - FileUtils.mkdir_p(@full_path, mode: 0770 ) - cmd = "cd #{@full_path} && git init --bare" + FileUtils.mkdir_p(@full_path, mode: 0770) + cmd = "cd #{@full_path} && git init --bare && ln -s #{@hook_path} #{@full_path}/hooks/post-receive" system(cmd) end |