Commit 64296a0d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Pass tag name to update hook too

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 3a960b7e
...@@ -5,7 +5,7 @@ require 'json' ...@@ -5,7 +5,7 @@ require 'json'
class GitlabUpdate class GitlabUpdate
attr_reader :config attr_reader :config
def initialize(repo_path, actor, refname) def initialize(repo_path, actor, ref)
@config = GitlabConfig.new @config = GitlabConfig.new
@repo_path = repo_path.strip @repo_path = repo_path.strip
...@@ -15,8 +15,8 @@ class GitlabUpdate ...@@ -15,8 +15,8 @@ class GitlabUpdate
@repo_name.gsub!(/^\//, "") @repo_name.gsub!(/^\//, "")
@actor = actor @actor = actor
@refname = refname @ref = ref
@branch_name = /refs\/heads\/([\/\w\.-]+)/.match(refname).to_a.last @ref_name = ref.gsub(/\Arefs\/(tags|heads)\//, '')
@oldrev = ARGV[1] @oldrev = ARGV[1]
@newrev = ARGV[2] @newrev = ARGV[2]
...@@ -27,11 +27,11 @@ class GitlabUpdate ...@@ -27,11 +27,11 @@ class GitlabUpdate
# get value from it # get value from it
ENV['GL_ID'] = nil 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 update_redis
exit 0 exit 0
else else
puts "GitLab: You are not allowed to access #{@branch_name}!" puts "GitLab: You are not allowed to access #{@ref_name}!"
exit 1 exit 1
end end
end end
...@@ -44,7 +44,7 @@ class GitlabUpdate ...@@ -44,7 +44,7 @@ class GitlabUpdate
def update_redis def update_redis
queue = "#{config.redis_namespace}:queue:post_receive" 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') unless system(*config.redis_command, 'rpush', queue, msg, err: '/dev/null', out: '/dev/null')
puts "GitLab: An unexpected error occurred (redis-cli returned #{$?.exitstatus})." puts "GitLab: An unexpected error occurred (redis-cli returned #{$?.exitstatus})."
exit 1 exit 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment