From b81ed87e4e8330295d0e12cd70a04e96c41e6992 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 15 Sep 2020 15:44:35 +0200 Subject: 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. --- ruby/lib/gitlab/git/hook.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ruby') 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 -- cgit v1.2.3