summaryrefslogtreecommitdiff
path: root/lib/gitlab_custom_hook.rb
diff options
context:
space:
mode:
authorDirk Hörner <dirker@gmail.com>2016-09-05 11:59:25 +0200
committerSean McGivern <sean@gitlab.com>2016-12-01 11:40:11 +0000
commitd05522de85dcdfa91349c0d9fc78bf72931d6a39 (patch)
tree30326e051959be5a7ddf6539b3c63fa48aa7330c /lib/gitlab_custom_hook.rb
parent2d774eeae8ccfb211cc6ab6aeab5db600f3fdc7c (diff)
downloadgitlab-shell-d05522de85dcdfa91349c0d9fc78bf72931d6a39.tar.gz
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.
Diffstat (limited to 'lib/gitlab_custom_hook.rb')
-rw-r--r--lib/gitlab_custom_hook.rb15
1 files changed, 8 insertions, 7 deletions
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) }