From cda96eb70992cc80d0dde8195df57d7b5c4a1429 Mon Sep 17 00:00:00 2001 From: Ash McKenzie Date: Tue, 31 Jul 2018 15:50:31 +1000 Subject: Use gl_id instead of key_id - Is possible that gl_id could be a 'user_id' - Is a more accurate variable name --- hooks/post-receive | 6 +++--- hooks/pre-receive | 6 +++--- hooks/update | 4 ++-- lib/gitlab_custom_hook.rb | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hooks/post-receive b/hooks/post-receive index 30f4be1..33d9f8d 100755 --- a/hooks/post-receive +++ b/hooks/post-receive @@ -4,15 +4,15 @@ # will be processed properly. refs = $stdin.read -key_id = ENV.delete('GL_ID') +gl_id = ENV.delete('GL_ID') gl_repository = ENV['GL_REPOSITORY'] repo_path = Dir.pwd require_relative '../lib/gitlab_custom_hook' require_relative '../lib/gitlab_post_receive' -if GitlabPostReceive.new(gl_repository, repo_path, key_id, refs).exec && - GitlabCustomHook.new(repo_path, key_id).post_receive(refs) +if GitlabPostReceive.new(gl_repository, repo_path, gl_id, refs).exec && + GitlabCustomHook.new(repo_path, gl_id).post_receive(refs) exit 0 else exit 1 diff --git a/hooks/pre-receive b/hooks/pre-receive index 6ce5879..66c61d9 100755 --- a/hooks/pre-receive +++ b/hooks/pre-receive @@ -4,7 +4,7 @@ # will be processed properly. refs = $stdin.read -key_id = ENV.delete('GL_ID') +gl_id = ENV.delete('GL_ID') protocol = ENV.delete('GL_PROTOCOL') repo_path = Dir.pwd gl_repository = ENV['GL_REPOSITORY'] @@ -23,8 +23,8 @@ require_relative '../lib/gitlab_net' # last so that it only runs if everything else succeeded. On post-receive on the # other hand, we run GitlabPostReceive first because the push is already done # and we don't want to skip it if the custom hook fails. -if GitlabAccess.new(gl_repository, repo_path, key_id, refs, protocol).exec && - GitlabCustomHook.new(repo_path, key_id).pre_receive(refs) && +if GitlabAccess.new(gl_repository, repo_path, gl_id, refs, protocol).exec && + GitlabCustomHook.new(repo_path, gl_id).pre_receive(refs) && increase_reference_counter(gl_repository, repo_path) exit 0 else diff --git a/hooks/update b/hooks/update index 4c2fc08..263a3e8 100755 --- a/hooks/update +++ b/hooks/update @@ -7,11 +7,11 @@ ref_name = ARGV[0] old_value = ARGV[1] new_value = ARGV[2] repo_path = Dir.pwd -key_id = ENV.delete('GL_ID') +gl_id = ENV.delete('GL_ID') require_relative '../lib/gitlab_custom_hook' -if GitlabCustomHook.new(repo_path, key_id).update(ref_name, old_value, new_value) +if GitlabCustomHook.new(repo_path, gl_id).update(ref_name, old_value, new_value) exit 0 else exit 1 diff --git a/lib/gitlab_custom_hook.rb b/lib/gitlab_custom_hook.rb index 67096df..de6eb38 100644 --- a/lib/gitlab_custom_hook.rb +++ b/lib/gitlab_custom_hook.rb @@ -5,9 +5,9 @@ require_relative 'gitlab_metrics' class GitlabCustomHook attr_reader :vars, :config - def initialize(repo_path, key_id) + def initialize(repo_path, gl_id) @repo_path = repo_path - @vars = { 'GL_ID' => key_id } + @vars = { 'GL_ID' => gl_id } @config = GitlabConfig.new end -- cgit v1.2.1