summaryrefslogtreecommitdiff
path: root/lib/gitlab_update.rb
diff options
context:
space:
mode:
authorGitLab <projects@quackenbush.me>2013-04-10 11:05:53 -0700
committerGitLab <projects@quackenbush.me>2013-04-10 11:05:53 -0700
commit2d98c91819bdf8f1b239fc3c421654e298e86d3c (patch)
tree12d6114d8408c49feeed1f5e5281da283949871d /lib/gitlab_update.rb
parentdec440f634a0cfb2e7e7d0477a03c22be33dd257 (diff)
downloadgitlab-shell-2d98c91819bdf8f1b239fc3c421654e298e86d3c.tar.gz
Refactored update hook as well as fixed a typo. GitlabConfig is now only called once in the update hook.
Diffstat (limited to 'lib/gitlab_update.rb')
-rw-r--r--lib/gitlab_update.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/gitlab_update.rb b/lib/gitlab_update.rb
index c222af3..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!(/^\//, "")
@@ -16,7 +18,7 @@ class GitlabUpdate
@oldrev = ARGV[1]
@newrev = ARGV[2]
- @redis = GitlabConfig.new.redis
+ @redis = config.redis
end
def exec
@@ -52,15 +54,15 @@ class GitlabUpdate
def update_redis
if !@redis.empty? && !@redis.has_key?("socket")
- redis_command = "#{@redis['bin']} -h #{@redis['host']} -p #{@redis['port']} rpush '#{@redis['namespace']}:queue:post_receive'"
+ redis_command = "#{@redis['bin']} -h #{@redis['host']} -p #{@redis['port']}"
elsif !@redis.empty? && @redis.has_key?("socket")
- redis_command = "#{@redis['bin']} -s #{@redis['socket']} rpush '#{@redis['namespace']}:queue:post_receive'"
+ 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_commend = "env -i redis-cli"
+ redis_command = "env -i redis-cli"
end
- command = "#{redis_command} '{\"class\":\"PostReceive\",\"args\":[\"#{@repo_path}\",\"#{@oldrev}\",\"#{@newrev}\",\"#{@refname}\",\"#{@key_id}\"]}' > /dev/null 2>&1"
+ 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