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'
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
......
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