diff options
Diffstat (limited to 'cmd/gitaly-hooks')
-rw-r--r-- | cmd/gitaly-hooks/hooks.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go index d94ecba05..70ea5d83e 100644 --- a/cmd/gitaly-hooks/hooks.go +++ b/cmd/gitaly-hooks/hooks.go @@ -25,25 +25,31 @@ import ( ) type hookCommand struct { - exec func(context.Context, git.HooksPayload, gitalypb.HookServiceClient, []string) (int, error) + exec func(context.Context, git.HooksPayload, gitalypb.HookServiceClient, []string) (int, error) + hookType git.Hook } var ( hooksBySubcommand = map[string]hookCommand{ "update": hookCommand{ - exec: updateHook, + exec: updateHook, + hookType: git.UpdateHook, }, "pre-receive": hookCommand{ - exec: preReceiveHook, + exec: preReceiveHook, + hookType: git.PreReceiveHook, }, "post-receive": hookCommand{ - exec: postReceiveHook, + exec: postReceiveHook, + hookType: git.PostReceiveHook, }, "reference-transaction": hookCommand{ - exec: referenceTransactionHook, + exec: referenceTransactionHook, + hookType: git.ReferenceTransactionHook, }, "git": hookCommand{ - exec: packObjectsHook, + exec: packObjectsHook, + hookType: git.PackObjectsHook, }, } @@ -102,6 +108,12 @@ func main() { logger.Fatalf("subcommand name invalid: %q", subCmd) } + // If the hook wasn't requested, then we simply skip executing any + // logic. + if !payload.IsHookRequested(hookCommand.hookType) { + os.Exit(0) + } + conn, err := dialGitaly(payload) if err != nil { logger.Fatalf("error when connecting to gitaly: %v", err) |