diff --git a/changelogs/unreleased/smh-enable-user-commit-files.yml b/changelogs/unreleased/smh-enable-user-commit-files.yml new file mode 100644 index 0000000000000000000000000000000000000000..2334da4d3e481cda2b2d122c67ccc50478d50739 --- /dev/null +++ b/changelogs/unreleased/smh-enable-user-commit-files.yml @@ -0,0 +1,5 @@ +--- +title: Enable Go port of UserCommitFiles by default +merge_request: 2922 +author: +type: performance diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go index 73f1a38fa7c6681d921e514c5da32d61b2fe5af1..eb43165752df2f9e20fc9682ab293bce8eefbac6 100644 --- a/cmd/gitaly/main.go +++ b/cmd/gitaly/main.go @@ -127,6 +127,7 @@ func run(b *bootstrap.Bootstrap) error { var gitlabAPI hook.GitlabAPI var err error + hookManager := hook.Manager(hook.DisabledManager{}) if config.SkipHooks() { log.Warn("skipping GitLab API client creation since hooks are bypassed via GITALY_TESTING_NO_GIT_HOOKS") } else { @@ -134,10 +135,12 @@ func run(b *bootstrap.Bootstrap) error { if err != nil { log.Fatalf("could not create GitLab API client: %v", err) } - } - hookManager := hook.NewManager(config.NewLocator(config.Config), gitlabAPI, config.Config) - prometheus.MustRegister(hookManager) + hm := hook.NewManager(config.NewLocator(config.Config), gitlabAPI, config.Config) + prometheus.MustRegister(hm) + + hookManager = hm + } conns := client.NewPoolWithOptions( client.WithDialer(client.HealthCheckDialer(client.DialContext)), diff --git a/internal/gitaly/hook/disabled_manager.go b/internal/gitaly/hook/disabled_manager.go new file mode 100644 index 0000000000000000000000000000000000000000..192739aefd70182955fd9559087b941dfa046fc2 --- /dev/null +++ b/internal/gitaly/hook/disabled_manager.go @@ -0,0 +1,31 @@ +package hook + +import ( + "context" + "io" + + "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" +) + +// DisabledManager never executes hooks and simply returns a nil error. +type DisabledManager struct{} + +// PreReceiveHook ignores its parameters and returns a nil error. +func (DisabledManager) PreReceiveHook(context.Context, *gitalypb.Repository, []string, io.Reader, io.Writer, io.Writer) error { + return nil +} + +// PostReceiveHook ignores its parameters and returns a nil error. +func (DisabledManager) PostReceiveHook(context.Context, *gitalypb.Repository, []string, []string, io.Reader, io.Writer, io.Writer) error { + return nil +} + +// UpdateHook ignores its parameters and returns a nil error. +func (DisabledManager) UpdateHook(context.Context, *gitalypb.Repository, string, string, string, []string, io.Writer, io.Writer) error { + return nil +} + +// ReferenceTransactionHook ignores its parameters and returns a nil error. +func (DisabledManager) ReferenceTransactionHook(context.Context, ReferenceTransactionState, []string, io.Reader) error { + return nil +} diff --git a/internal/metadata/featureflag/feature_flags.go b/internal/metadata/featureflag/feature_flags.go index d4f33cc582befd305c4cc553b9e2caa6fa3922e5..d9e2fb9f2935aad973f5b6f310d4e75ac3b3e9ac 100644 --- a/internal/metadata/featureflag/feature_flags.go +++ b/internal/metadata/featureflag/feature_flags.go @@ -28,7 +28,7 @@ var ( // GoUserSquash enables the Go implementation of UserSquash GoUserSquash = FeatureFlag{Name: "go_user_squash", OnByDefault: true} // GoUserCommitFiles enables the Go implementation of UserCommitFiles - GoUserCommitFiles = FeatureFlag{Name: "go_user_commit_files", OnByDefault: false} + GoUserCommitFiles = FeatureFlag{Name: "go_user_commit_files", OnByDefault: true} // GoResolveConflicts enables the Go implementation of ResolveConflicts GoResolveConflicts = FeatureFlag{Name: "go_resolve_conflicts", OnByDefault: false} // GoUserUpdateSubmodule enables the Go implementation of