From d05522de85dcdfa91349c0d9fc78bf72931d6a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20H=C3=B6rner?= Date: Mon, 5 Sep 2016 11:59:25 +0200 Subject: custom_hook: refactor to pull repo_path into class This commit takes the GitlabCustomHook a bit clother to the other hook handling classes by receiving the repo_path as argument to initialize() instead of passing it to each method. --- lib/gitlab_custom_hook.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/gitlab_custom_hook.rb') diff --git a/lib/gitlab_custom_hook.rb b/lib/gitlab_custom_hook.rb index e84d702..0187e1e 100644 --- a/lib/gitlab_custom_hook.rb +++ b/lib/gitlab_custom_hook.rb @@ -5,26 +5,27 @@ require_relative 'gitlab_metrics' class GitlabCustomHook attr_reader :vars - def initialize(key_id) + def initialize(repo_path, key_id) + @repo_path = repo_path @vars = { 'GL_ID' => key_id } end - def pre_receive(changes, repo_path) - hook = hook_file('pre-receive', repo_path) + def pre_receive(changes) + hook = hook_file('pre-receive', @repo_path) return true if hook.nil? GitlabMetrics.measure("pre-receive-hook") { call_receive_hook(hook, changes) } end - def post_receive(changes, repo_path) - hook = hook_file('post-receive', repo_path) + def post_receive(changes) + hook = hook_file('post-receive', @repo_path) return true if hook.nil? GitlabMetrics.measure("post-receive-hook") { call_receive_hook(hook, changes) } end - def update(ref_name, old_value, new_value, repo_path) - hook = hook_file('update', repo_path) + def update(ref_name, old_value, new_value) + hook = hook_file('update', @repo_path) return true if hook.nil? GitlabMetrics.measure("update-hook") { system(vars, hook, ref_name, old_value, new_value) } -- cgit v1.2.1