diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-20 14:34:33 +0200 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-03-20 14:34:33 +0200 |
| commit | 64296a0d96039e7b44ef2ed4aad43383f8b0d63d (patch) | |
| tree | 5bca8db48d05dfb8549f624c6d72e4fcd7cd49a4 | |
| parent | 3a960b7e75ec5855ae202a888e3575b535c1f09c (diff) | |
| download | gitlab-shell-64296a0d96039e7b44ef2ed4aad43383f8b0d63d.tar.gz | |
Pass tag name to update hook too
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
| -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 |
