diff options
author | Karthik Nayak <knayak@gitlab.com> | 2023-12-07 20:52:42 +0300 |
---|---|---|
committer | Karthik Nayak <knayak@gitlab.com> | 2023-12-08 14:36:55 +0300 |
commit | 3c1fc525900d00291485a6f823455617e1264fb3 (patch) | |
tree | f90fc0955f4b7dce32b17691af694f10691e6d3f /internal/gitaly/hook/prereceive_test.go | |
parent | c0b07ba36fc8fc40830f061cb55a5c951a166e1c (diff) |
hook: Introduce `ProcReceiveHandler` and `ProcReceiveRegistry`
Introduce the `ProcReceiveHandler` which provides the mechanism for RPCs
which invoked git-receive-pack(1) to interact with the proc-receive
hook. It provides access to a list of references that a transaction is
attempting to update, and functions to accept or reject individual
updates.
Also, introduce `ProcReceiveRegistry`, a registry which provides the
proc-receive handlers against a provided transaction ID. The registry
allows RPCs which perform commands that execute git-receive-pack(1) to
hook into the proc-receive handler. The RPC must register itself with
the registry by calling RegisterWaiter(), this provides a channel where
the handler will be provided along with a registry cleanup function.
Diffstat (limited to 'internal/gitaly/hook/prereceive_test.go')
-rw-r--r-- | internal/gitaly/hook/prereceive_test.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/internal/gitaly/hook/prereceive_test.go b/internal/gitaly/hook/prereceive_test.go index 77f6bb4a1..1bfab9447 100644 --- a/internal/gitaly/hook/prereceive_test.go +++ b/internal/gitaly/hook/prereceive_test.go @@ -43,7 +43,7 @@ func TestPrereceive_customHooks(t *testing.T) { txManager := transaction.NewTrackingManager() hookManager := NewManager(cfg, locator, testhelper.SharedLogger(t), gitCmdFactory, txManager, gitlab.NewMockClient( t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive, - ), NewTransactionRegistry(storagemgr.NewTransactionRegistry())) + ), NewTransactionRegistry(storagemgr.NewTransactionRegistry()), NewProcReceiveRegistry()) receiveHooksPayload := &git.UserDetails{ UserID: "1234", @@ -228,7 +228,7 @@ func TestPrereceive_quarantine(t *testing.T) { hookManager := NewManager(cfg, config.NewLocator(cfg), testhelper.SharedLogger(t), gittest.NewCommandFactory(t, cfg), nil, gitlab.NewMockClient( t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive, - ), NewTransactionRegistry(storagemgr.NewTransactionRegistry())) + ), NewTransactionRegistry(storagemgr.NewTransactionRegistry()), NewProcReceiveRegistry()) //nolint:gitaly-linters gittest.WriteCustomHook(t, repoPath, "pre-receive", []byte(fmt.Sprintf( @@ -419,7 +419,16 @@ func TestPrereceive_gitlab(t *testing.T) { }, } - hookManager := NewManager(cfg, config.NewLocator(cfg), testhelper.SharedLogger(t), gittest.NewCommandFactory(t, cfg), transaction.NewManager(cfg, testhelper.SharedLogger(t), backchannel.NewRegistry()), &gitlabAPI, NewTransactionRegistry(storagemgr.NewTransactionRegistry())) + hookManager := NewManager( + cfg, + config.NewLocator(cfg), + testhelper.SharedLogger(t), + gittest.NewCommandFactory(t, cfg), + transaction.NewManager(cfg, testhelper.SharedLogger(t), backchannel.NewRegistry()), + &gitlabAPI, + NewTransactionRegistry(storagemgr.NewTransactionRegistry()), + NewProcReceiveRegistry(), + ) gittest.WriteCustomHook(t, repoPath, "pre-receive", []byte("#!/bin/sh\necho called\n")) |