Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-09-15 16:44:35 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-09-16 09:20:12 +0300
commitb81ed87e4e8330295d0e12cd70a04e96c41e6992 (patch)
treeecb14b7ed326256d8e2c93d3c0d5f7f9e0f8c9da /ruby
parent6d027f267769398654a92e9b63adc3fd271db914 (diff)
hooks: Implement calling the reference-transaction hook
To enable the transition from voting on reference transaction via the pre-receive hook towards the reference-transaction hook, we'll have to start calling the latter from our Ruby sidecar. This commit thus implements the logic to invoke the reference transaction hook, but doesn't yet wire up this new hook implementation.
Diffstat (limited to 'ruby')
-rw-r--r--ruby/lib/gitlab/git/hook.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/ruby/lib/gitlab/git/hook.rb b/ruby/lib/gitlab/git/hook.rb
index dd3875d2f..8a514da2c 100644
--- a/ruby/lib/gitlab/git/hook.rb
+++ b/ruby/lib/gitlab/git/hook.rb
@@ -35,6 +35,8 @@ module Gitlab
case name
when "pre-receive", "post-receive"
call_receive_hook(gl_id, gl_username, oldrev, newrev, ref, push_options, transaction)
+ when "reference-transaction"
+ call_reference_transaction_hook(gl_id, gl_username, oldrev, newrev, ref, transaction)
when "update"
call_update_hook(gl_id, gl_username, oldrev, newrev, ref)
end
@@ -85,6 +87,15 @@ module Gitlab
call_stdin_hook([], changes, vars)
end
+ def call_reference_transaction_hook(gl_id, gl_username, oldrev, newrev, ref, transaction)
+ changes = [oldrev, newrev, ref].join(" ")
+
+ vars = env_base_vars(gl_id, gl_username)
+ vars.merge!(transaction.env_vars) if transaction
+
+ call_stdin_hook(["prepared"], changes, vars)
+ end
+
def call_update_hook(gl_id, gl_username, oldrev, newrev, ref)
options = {
chdir: repo_path