summaryrefslogtreecommitdiff
path: root/lib/gitlab_post_receive.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-01 19:00:06 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-01 19:00:06 +0300
commit119aae7d71cac17af9a68122c8b3021adf5cbfd9 (patch)
tree40c4756ad1b647dd655c13b0805ecf14ae2be372 /lib/gitlab_post_receive.rb
parentc6909d0c941784d60cb552d5685e1ff808323991 (diff)
downloadgitlab-shell-119aae7d71cac17af9a68122c8b3021adf5cbfd9.tar.gz
GitlabAccess and GitlabPostReceive classes added
Gitlab Access handles security check. GitlabPostReceive creates a sidekiq job Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/gitlab_post_receive.rb')
-rw-r--r--lib/gitlab_post_receive.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb
new file mode 100644
index 0000000..3f9f384
--- /dev/null
+++ b/lib/gitlab_post_receive.rb
@@ -0,0 +1,31 @@
+require_relative 'gitlab_init'
+require 'json'
+
+class GitlabPostReceive
+ attr_reader :config, :repo_path, :changes
+
+ def initialize(repo_path, actor, changes)
+ @config = GitlabConfig.new
+ @repo_path, @actor = repo_path.strip, actor
+ @changes = changes.lines
+ end
+
+ def exec
+ # reset GL_ID env since we already
+ # get value from it
+ ENV['GL_ID'] = nil
+
+ update_redis
+ end
+
+ protected
+
+ def update_redis
+ queue = "#{config.redis_namespace}:queue:post_receive"
+ msg = JSON.dump({'class' => 'PostReceive', 'args' => [@repo_path, @actor, @changes]})
+ unless system(*config.redis_command, 'rpush', queue, msg, err: '/dev/null', out: '/dev/null')
+ puts "GitLab: An unexpected error occurred (redis-cli returned #{$?.exitstatus})."
+ exit 1
+ end
+ end
+end