summaryrefslogtreecommitdiff
path: root/lib/gitlab_update.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab_update.rb')
-rw-r--r--lib/gitlab_update.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/gitlab_update.rb b/lib/gitlab_update.rb
index 8282897..a486ecc 100644
--- a/lib/gitlab_update.rb
+++ b/lib/gitlab_update.rb
@@ -3,9 +3,11 @@ require_relative 'gitlab_net'
class GitlabUpdate
def initialize(repo_path, key_id, refname)
+ config = GitlabConfig.new
+
@repo_path = repo_path.strip
@repo_name = repo_path
- @repo_name.gsub!(GitlabConfig.new.repos_path.to_s, "")
+ @repo_name.gsub!(config.repos_path.to_s, "")
@repo_name.gsub!(/\.git$/, "")
@repo_name.gsub!(/^\//, "")
@@ -15,6 +17,8 @@ class GitlabUpdate
@oldrev = ARGV[1]
@newrev = ARGV[2]
+
+ @redis = config.redis
end
def exec
@@ -49,7 +53,16 @@ class GitlabUpdate
end
def update_redis
- command = "env -i redis-cli rpush 'resque:gitlab:queue:post_receive' '{\"class\":\"PostReceive\",\"args\":[\"#{@repo_path}\",\"#{@oldrev}\",\"#{@newrev}\",\"#{@refname}\",\"#{@key_id}\"]}' > /dev/null 2>&1"
+ if !@redis.empty? && !@redis.has_key?("socket")
+ redis_command = "#{@redis['bin']} -h #{@redis['host']} -p #{@redis['port']}"
+ elsif !@redis.empty? && @redis.has_key?("socket")
+ redis_command = "#{@redis['bin']} -s #{@redis['socket']}"
+ else
+ # Default to old method of connecting to redis for users that haven't updated their configuration
+ redis_command = "env -i redis-cli"
+ end
+
+ command = "#{redis_command} rpush '#{@redis['namespace']}:queue:post_receive' '{\"class\":\"PostReceive\",\"args\":[\"#{@repo_path}\",\"#{@oldrev}\",\"#{@newrev}\",\"#{@refname}\",\"#{@key_id}\"]}' > /dev/null 2>&1"
system(command)
end
end