diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab_update.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/gitlab_update.rb b/lib/gitlab_update.rb index 6ce6952..742d5fd 100644 --- a/lib/gitlab_update.rb +++ b/lib/gitlab_update.rb @@ -5,7 +5,7 @@ require 'json' class GitlabUpdate attr_reader :config - def initialize(repo_path, actor, refname) + def initialize(repo_path, actor, ref) @config = GitlabConfig.new @repo_path = repo_path.strip @@ -15,8 +15,8 @@ class GitlabUpdate @repo_name.gsub!(/^\//, "") @actor = actor - @refname = refname - @branch_name = /refs\/heads\/([\/\w\.-]+)/.match(refname).to_a.last + @ref = ref + @ref_name = ref.gsub(/\Arefs\/(tags|heads)\//, '') @oldrev = ARGV[1] @newrev = ARGV[2] @@ -27,11 +27,11 @@ class GitlabUpdate # get value from it ENV['GL_ID'] = nil - if api.allowed?('git-receive-pack', @repo_name, @actor, @branch_name, @oldrev, @newrev) + if api.allowed?('git-receive-pack', @repo_name, @actor, @ref_name, @oldrev, @newrev) update_redis exit 0 else - puts "GitLab: You are not allowed to access #{@branch_name}!" + puts "GitLab: You are not allowed to access #{@ref_name}!" exit 1 end end @@ -44,7 +44,7 @@ class GitlabUpdate def update_redis queue = "#{config.redis_namespace}:queue:post_receive" - msg = JSON.dump({'class' => 'PostReceive', 'args' => [@repo_path, @oldrev, @newrev, @refname, @actor]}) + msg = JSON.dump({'class' => 'PostReceive', 'args' => [@repo_path, @oldrev, @newrev, @ref, @actor]}) 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 |
