diff options
author | Dirk Hörner <dirker@gmail.com> | 2016-09-05 11:59:25 +0200 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-12-01 11:40:11 +0000 |
commit | d05522de85dcdfa91349c0d9fc78bf72931d6a39 (patch) | |
tree | 30326e051959be5a7ddf6539b3c63fa48aa7330c /lib/gitlab_custom_hook.rb | |
parent | 2d774eeae8ccfb211cc6ab6aeab5db600f3fdc7c (diff) | |
download | gitlab-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.rb | 15 |
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) } |