summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2016-10-05 08:55:07 +0000
committerSean McGivern <sean@mcgivern.me.uk>2016-10-05 08:55:07 +0000
commitfad9498c1b15e96bf553064d77dc33c17ff7baa7 (patch)
tree9b9e6cd85dd28ed8e6240cebfc958e867ca02313 /lib
parentc04e2ae0e8a7d8501f57424f4a118d05db2527bd (diff)
parentc0b473418296764764cb716686cd870e7018b242 (diff)
downloadgitlab-shell-fad9498c1b15e96bf553064d77dc33c17ff7baa7.tar.gz
Merge branch 'add_gl_id' into 'master'
Re-exposing GL_ID to custom hooks closes https://gitlab.com/gitlab-org/gitlab-ee/issues/995 closes https://gitlab.com/gitlab-org/gitlab-shell/issues/53 See merge request !95
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab_custom_hook.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/gitlab_custom_hook.rb b/lib/gitlab_custom_hook.rb
index fe6cff3..4edb48b 100644
--- a/lib/gitlab_custom_hook.rb
+++ b/lib/gitlab_custom_hook.rb
@@ -1,6 +1,12 @@
require 'open3'
class GitlabCustomHook
+ attr_reader :vars
+
+ def initialize(key_id)
+ @vars = { 'GL_ID' => key_id }
+ end
+
def pre_receive(changes, repo_path)
hook = hook_file('pre-receive', repo_path)
return true if hook.nil?
@@ -11,7 +17,7 @@ class GitlabCustomHook
def post_receive(changes, repo_path)
hook = hook_file('post-receive', repo_path)
return true if hook.nil?
-
+
call_receive_hook(hook, changes)
end
@@ -19,7 +25,7 @@ class GitlabCustomHook
hook = hook_file('update', repo_path)
return true if hook.nil?
- system(hook, ref_name, old_value, new_value)
+ system(vars, hook, ref_name, old_value, new_value)
end
private
@@ -28,7 +34,7 @@ class GitlabCustomHook
# Prepare the hook subprocess. Attach a pipe to its stdin, and merge
# both its stdout and stderr into our own stdout.
stdin_reader, stdin_writer = IO.pipe
- hook_pid = spawn(hook, in: stdin_reader, err: :out)
+ hook_pid = spawn(vars, hook, in: stdin_reader, err: :out)
stdin_reader.close
# Submit changes to the hook via its stdin.