diff options
Diffstat (limited to 'internal')
40 files changed, 21 insertions, 481 deletions
diff --git a/internal/cli/gitaly/serve.go b/internal/cli/gitaly/serve.go index 825bb19d8..989c175c3 100644 --- a/internal/cli/gitaly/serve.go +++ b/internal/cli/gitaly/serve.go @@ -23,7 +23,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping" "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo" - "gitlab.com/gitlab-org/gitaly/v16/internal/git2go" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config/sentry" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook" @@ -320,8 +319,6 @@ func run(cfg config.Cfg, logger logrus.FieldLogger) error { ) defer gitalyServerFactory.Stop() - git2goExecutor := git2go.NewExecutor(cfg, gitCmdFactory, locator, logger) - updaterWithHooks := updateref.NewUpdaterWithHooks(cfg, locator, hookManager, gitCmdFactory, catfileCache) streamCache := streamcache.New(cfg.PackObjectsCache, logger) @@ -375,7 +372,6 @@ func run(cfg config.Cfg, logger logrus.FieldLogger) error { PackObjectsCache: streamCache, PackObjectsLimiter: packObjectsLimiter, RepositoryCounter: repoCounter, - Git2goExecutor: git2goExecutor, UpdaterWithHooks: updaterWithHooks, HousekeepingManager: housekeepingManager, BackupSink: backupSink, diff --git a/internal/git/localrepo/remote_extra_test.go b/internal/git/localrepo/remote_extra_test.go index 0dcd2188e..4e4f693ce 100644 --- a/internal/git/localrepo/remote_extra_test.go +++ b/internal/git/localrepo/remote_extra_test.go @@ -48,7 +48,6 @@ func TestRepo_FetchInternal(t *testing.T) { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/git/remoterepo/testhelper_test.go b/internal/git/remoterepo/testhelper_test.go index ebac4880c..2a9b0ce9b 100644 --- a/internal/git/remoterepo/testhelper_test.go +++ b/internal/git/remoterepo/testhelper_test.go @@ -30,7 +30,6 @@ func setupGitalyServer(t *testing.T) config.Cfg { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/git2go/executor.go b/internal/git2go/executor.go deleted file mode 100644 index f5cca8252..000000000 --- a/internal/git2go/executor.go +++ /dev/null @@ -1,142 +0,0 @@ -package git2go - -import ( - "bytes" - "context" - "encoding/gob" - "errors" - "fmt" - "io" - "strings" - - "github.com/sirupsen/logrus" - "gitlab.com/gitlab-org/gitaly/v16/internal/command" - "gitlab.com/gitlab-org/gitaly/v16/internal/featureflag" - "gitlab.com/gitlab-org/gitaly/v16/internal/git" - "gitlab.com/gitlab-org/gitaly/v16/internal/git/alternates" - "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" - "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage" - "gitlab.com/gitlab-org/labkit/correlation" -) - -var ( - // ErrInvalidArgument is returned in case the merge arguments are invalid. - ErrInvalidArgument = errors.New("invalid parameters") - - // BinaryName is the name of the gitaly-git2go binary. - BinaryName = "gitaly-git2go" -) - -// Executor executes gitaly-git2go. -type Executor struct { - binaryPath string - signingKey string - gitCmdFactory git.CommandFactory - locator storage.Locator - logger logrus.FieldLogger - logFormat, logLevel string -} - -// NewExecutor returns a new gitaly-git2go executor using binaries as configured in the given -// configuration. -func NewExecutor(cfg config.Cfg, gitCmdFactory git.CommandFactory, locator storage.Locator, logger logrus.FieldLogger) *Executor { - return &Executor{ - binaryPath: cfg.BinaryPath(BinaryName), - signingKey: cfg.Git.SigningKey, - gitCmdFactory: gitCmdFactory, - locator: locator, - logger: logger, - logFormat: cfg.Logging.Format, - logLevel: cfg.Logging.Level, - } -} - -func (b *Executor) run(ctx context.Context, repo storage.Repository, stdin io.Reader, subcmd string, args ...string) (*bytes.Buffer, error) { - repoPath, err := b.locator.GetRepoPath(repo) - if err != nil { - return nil, fmt.Errorf("gitaly-git2go: %w", err) - } - - var enabledFeatureFlags, disabledFeatureFlags []string - - for flag, value := range featureflag.FromContext(ctx) { - switch value { - case true: - enabledFeatureFlags = append(enabledFeatureFlags, flag.MetadataKey()) - case false: - disabledFeatureFlags = append(disabledFeatureFlags, flag.MetadataKey()) - } - } - - env := alternates.Env(repoPath, repo.GetGitObjectDirectory(), repo.GetGitAlternateObjectDirectories()) - env = append(env, b.gitCmdFactory.GetExecutionEnvironment(ctx).EnvironmentVariables...) - - // Construct a log writer that we pass to gitaly-git2go. Note that this is not exactly pretty: the output - // generated by the logger is not going to be parsed, but will be written to the log without any change as log - // message. - // - // Previously, we would have written these messages to `logrus.Logger.Out` directly. But we have refactored our - // code to get rid of the global logger instance, and thus we cannot access that field anymore. Given that the - // git2go executor is going away next release anyway, let's just live with this ugly workaround here. We still - // have visibility into what the process is doing, but with a bit less comfort. That seems like an acceptable - // tradeoff in order to get rid of the global logger altogether. - logWriter := b.logger.WithField("component", "git2go."+subcmd).Writer() - defer logWriter.Close() - - args = append([]string{ - "-log-format", b.logFormat, - "-log-level", b.logLevel, - "-correlation-id", correlation.ExtractFromContext(ctx), - "-enabled-feature-flags", strings.Join(enabledFeatureFlags, ","), - "-disabled-feature-flags", strings.Join(disabledFeatureFlags, ","), - subcmd, - }, args...) - - var stdout bytes.Buffer - cmd, err := command.New(ctx, append([]string{b.binaryPath}, args...), - command.WithStdin(stdin), - command.WithStdout(&stdout), - command.WithStderr(logWriter), - command.WithEnvironment(env), - command.WithCommandName("gitaly-git2go", subcmd), - ) - if err != nil { - return nil, err - } - - if err := cmd.Wait(); err != nil { - return nil, err - } - - return &stdout, nil -} - -// runWithGob runs the specified gitaly-git2go cmd with the request gob-encoded -// as input and returns the commit ID as string or an error. -func (b *Executor) runWithGob(ctx context.Context, repo storage.Repository, cmd string, request interface{}) (git.ObjectID, error) { - input := &bytes.Buffer{} - if err := gob.NewEncoder(input).Encode(request); err != nil { - return "", fmt.Errorf("%s: %w", cmd, err) - } - - output, err := b.run(ctx, repo, input, cmd) - if err != nil { - return "", fmt.Errorf("%s: %w", cmd, err) - } - - var result Result - if err := gob.NewDecoder(output).Decode(&result); err != nil { - return "", fmt.Errorf("%s: %w", cmd, err) - } - - if result.Err != nil { - return "", fmt.Errorf("%s: %w", cmd, result.Err) - } - - commitID, err := git.ObjectHashSHA1.FromHex(result.CommitID) - if err != nil { - return "", fmt.Errorf("could not parse commit ID: %w", err) - } - - return commitID, nil -} diff --git a/internal/git2go/featureflags.go b/internal/git2go/featureflags.go deleted file mode 100644 index bfde6867b..000000000 --- a/internal/git2go/featureflags.go +++ /dev/null @@ -1,22 +0,0 @@ -package git2go - -// FeatureFlag is a feature flag state as seen by the `gitaly-git2go featureflag` test subcommand. -type FeatureFlag struct { - // MetadataKey is the metadata key of the feature flag. - MetadataKey string - // Name is the name of the feature flag. - Name string - // Value is the value of the feature flag. - Value bool -} - -// FeatureFlags is a struct only used by tests to confirm that feature flags are -// being properly propagated from the git2go Executor to the gitaly-git2go -// binary -type FeatureFlags struct { - // Flags is the set of feature flags observed by the command. - Flags []FeatureFlag - // Err is set if an error occurred. Err must exist on all gob serialized - // results so that any error can be returned. - Err error -} diff --git a/internal/git2go/featureflags_test.go b/internal/git2go/featureflags_test.go deleted file mode 100644 index db2a35992..000000000 --- a/internal/git2go/featureflags_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package git2go - -import ( - "context" - "encoding/gob" - "testing" - - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/v16/internal/featureflag" - "gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest" - "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo" - "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" - "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage" - "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper" - "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg" -) - -func (b *Executor) FeatureFlags(ctx context.Context, repo storage.Repository) ([]FeatureFlag, error) { - output, err := b.run(ctx, repo, nil, "feature-flags") - if err != nil { - return nil, err - } - - var result FeatureFlags - if err := gob.NewDecoder(output).Decode(&result); err != nil { - return nil, err - } - - if result.Err != nil { - return nil, result.Err - } - - return result.Flags, err -} - -var ( - featureA = featureflag.NewFeatureFlag("feature_a", "", "", false) - featureB = featureflag.NewFeatureFlag("feature_b", "", "", true) -) - -func TestExecutor_explicitFeatureFlags(t *testing.T) { - testhelper.NewFeatureSets(featureA, featureB).Run(t, testExecutorFeatureFlags) -} - -func testExecutorFeatureFlags(t *testing.T, ctx context.Context) { - cfg := testcfg.Build(t) - testcfg.BuildGitalyGit2Go(t, cfg) - - repoProto, _ := gittest.CreateRepository(t, ctx, cfg, gittest.CreateRepositoryConfig{ - SkipCreationViaService: true, - }) - - repo := localrepo.NewTestRepo(t, cfg, repoProto) - - executor := NewExecutor(cfg, gittest.NewCommandFactory(t, cfg), config.NewLocator(cfg), testhelper.SharedLogger(t)) - - flags, err := executor.FeatureFlags(ctx, repo) - require.NoError(t, err) - - require.Subset(t, flags, []FeatureFlag{ - { - Name: "feature_a", - MetadataKey: "gitaly-feature-feature-a", - Value: featureA.IsEnabled(ctx), - }, - { - Name: "feature_b", - MetadataKey: "gitaly-feature-feature-b", - Value: featureB.IsEnabled(ctx), - }, - }, flags) -} diff --git a/internal/git2go/rebase.go b/internal/git2go/rebase.go deleted file mode 100644 index 3bdc0e9e6..000000000 --- a/internal/git2go/rebase.go +++ /dev/null @@ -1,42 +0,0 @@ -package git2go - -import ( - "context" - - "gitlab.com/gitlab-org/gitaly/v16/internal/git" - "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage" -) - -// RebaseCommand contains parameters to rebase a branch. -type RebaseCommand struct { - // Repository is the path to execute rebase in. - Repository string - // Committer contains the the committer signature. - Committer Signature - // BranchName is the branch that is rebased. Deprecated, can be removed in the next release. - BranchName string - // UpstreamRevision is the revision where the branch is rebased onto. Deprecated, can be - // removed in the next release. - UpstreamRevision string - // CommitID is the object ID of the commit that shall be rebased. Deprecates BranchName. - CommitID git.ObjectID - // UpstreamCommitID is the object ID of the commit which is considered to be the - // upstream branch. This parameter determines both the commit onto which we're - // about to rebase, which is the merge base of the upstream commit and rebased - // commit, and which commits should be rebased, which is the commit range - // upstream..commit. Deprecates the UpstreamRevision. - UpstreamCommitID git.ObjectID - // SkipEmptyCommits will cause commits which have already been applied on the target branch - // and which are thus empty to be skipped. If unset, empty commits will cause the rebase to - // fail. - SkipEmptyCommits bool - // SigningKey is a path to the key to sign commit using OpenPGP - SigningKey string -} - -// Rebase performs the rebase via gitaly-git2go -func (b *Executor) Rebase(ctx context.Context, repo storage.Repository, r RebaseCommand) (git.ObjectID, error) { - r.SigningKey = b.signingKey - - return b.runWithGob(ctx, repo, "rebase", r) -} diff --git a/internal/git2go/serialization.go b/internal/git2go/serialization.go deleted file mode 100644 index a1454e916..000000000 --- a/internal/git2go/serialization.go +++ /dev/null @@ -1,102 +0,0 @@ -package git2go - -import ( - "encoding/gob" - "errors" - "fmt" - "reflect" -) - -func init() { - for typeToRegister := range registeredTypes { - gob.Register(reflect.Zero(typeToRegister).Interface()) - } -} - -var registeredTypes = map[reflect.Type]struct{}{ - reflect.TypeOf(wrapError{}): {}, - reflect.TypeOf(HasConflictsError{}): {}, - reflect.TypeOf(ConflictingFilesError{}): {}, - reflect.TypeOf(EmptyError{}): {}, - reflect.TypeOf(CommitNotFoundError{}): {}, -} - -// Result is the serialized result. -type Result struct { - // CommitID is the result of the call. - CommitID string - // Err is set if an error occurred. Err must exist on all gob serialized - // results so that all errors can be returned. - Err error -} - -// wrapError is used to serialize wrapped errors as fmt.wrapError type only has -// private fields and can't be serialized via gob. It's also used to serialize unregistered -// error types by serializing only their error message. -type wrapError struct { - Message string - Err error -} - -func (err wrapError) Error() string { return err.Message } - -func (err wrapError) Unwrap() error { return err.Err } - -// HasConflictsError is used when a change, for example a revert, could not be -// applied due to a conflict. -type HasConflictsError struct{} - -func (err HasConflictsError) Error() string { - return "could not apply due to conflicts" -} - -// ConflictingFilesError is an error raised when there are conflicting files. -type ConflictingFilesError struct { - // ConflictingFiles is the set of files which have conflicts. - ConflictingFiles []string -} - -func (err ConflictingFilesError) Error() string { - return "there are conflicting files" -} - -// EmptyError indicates the command, for example cherry-pick, did result in no -// changes, so the result is empty. -type EmptyError struct{} - -func (err EmptyError) Error() string { - return "could not apply because the result was empty" -} - -// CommitNotFoundError indicates that the given commit rev could not be found. -type CommitNotFoundError struct { - // Revision used to lookup the commit - Revision string -} - -func (err CommitNotFoundError) Error() string { - return fmt.Sprintf("commit not found: %q", err.Revision) -} - -// SerializableError returns an error that is Gob serializable. -// Registered types are serialized directly. Unregistered types -// are transformed in to an opaque error using their error message. -// Wrapped errors remain unwrappable. -func SerializableError(err error) error { - if err == nil { - return nil - } - - if unwrappedErr := errors.Unwrap(err); unwrappedErr != nil { - return wrapError{ - Message: err.Error(), - Err: SerializableError(unwrappedErr), - } - } - - if _, ok := registeredTypes[reflect.TypeOf(err)]; !ok { - return wrapError{Message: err.Error()} - } - - return err -} diff --git a/internal/git2go/signature.go b/internal/git2go/signature.go deleted file mode 100644 index 1d66ed5e0..000000000 --- a/internal/git2go/signature.go +++ /dev/null @@ -1,9 +0,0 @@ -package git2go - -import "gitlab.com/gitlab-org/gitaly/v16/internal/git" - -// Signature represents a commits signature, synced from internal/git. -type Signature = git.Signature - -// NewSignature creates a new sanitized signature, syned from internal/git. -var NewSignature = git.NewSignature diff --git a/internal/git2go/testhelper_test.go b/internal/git2go/testhelper_test.go deleted file mode 100644 index f4298b718..000000000 --- a/internal/git2go/testhelper_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package git2go - -import ( - "testing" - - "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper" -) - -func TestMain(m *testing.M) { - testhelper.Run(m) -} diff --git a/internal/gitaly/config/config.go b/internal/gitaly/config/config.go index 1b4b7bbe0..a938b7c0c 100644 --- a/internal/gitaly/config/config.go +++ b/internal/gitaly/config/config.go @@ -759,7 +759,6 @@ func validateIsDirectory(path, name string) error { var packedBinaries = map[string]struct{}{ "gitaly-hooks": {}, "gitaly-ssh": {}, - "gitaly-git2go": {}, "gitaly-lfs-smudge": {}, "gitaly-gpg": {}, } diff --git a/internal/gitaly/service/blob/testhelper_test.go b/internal/gitaly/service/blob/testhelper_test.go index bf76a55cc..4ca1a85ae 100644 --- a/internal/gitaly/service/blob/testhelper_test.go +++ b/internal/gitaly/service/blob/testhelper_test.go @@ -36,7 +36,6 @@ func setup(tb testing.TB, ctx context.Context) (config.Cfg, gitalypb.BlobService deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/cleanup/testhelper_test.go b/internal/gitaly/service/cleanup/testhelper_test.go index 074a9052a..00f7a107a 100644 --- a/internal/gitaly/service/cleanup/testhelper_test.go +++ b/internal/gitaly/service/cleanup/testhelper_test.go @@ -54,7 +54,6 @@ func runCleanupServiceServer(t *testing.T, cfg config.Cfg) string { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/commit/testhelper_test.go b/internal/gitaly/service/commit/testhelper_test.go index d0b457d0e..44356057a 100644 --- a/internal/gitaly/service/commit/testhelper_test.go +++ b/internal/gitaly/service/commit/testhelper_test.go @@ -53,7 +53,6 @@ func startTestServices(tb testing.TB, cfg config.Cfg, opts ...testserver.GitalyS deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go index 813826e52..1d1b2f6e8 100644 --- a/internal/gitaly/service/conflicts/testhelper_test.go +++ b/internal/gitaly/service/conflicts/testhelper_test.go @@ -51,7 +51,6 @@ func runConflictsServer(tb testing.TB, cfg config.Cfg, hookManager hook.Manager) deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/dependencies.go b/internal/gitaly/service/dependencies.go index 664aeca96..d0f568af3 100644 --- a/internal/gitaly/service/dependencies.go +++ b/internal/gitaly/service/dependencies.go @@ -7,7 +7,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v16/internal/git" "gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping" - "gitlab.com/gitlab-org/gitaly/v16/internal/git2go" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" gitalyhook "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook/updateref" @@ -38,7 +37,6 @@ type Dependencies struct { PackObjectsLimiter limiter.Limiter LimitHandler *limithandler.LimiterMiddleware RepositoryCounter *counter.RepositoryCounter - Git2goExecutor *git2go.Executor UpdaterWithHooks *updateref.UpdaterWithHooks HousekeepingManager housekeeping.Manager PartitionManager *storagemgr.PartitionManager @@ -111,11 +109,6 @@ func (dc *Dependencies) GetRepositoryCounter() *counter.RepositoryCounter { return dc.RepositoryCounter } -// GetGit2goExecutor returns the git2go executor. -func (dc *Dependencies) GetGit2goExecutor() *git2go.Executor { - return dc.Git2goExecutor -} - // GetUpdaterWithHooks returns the updater with hooks executor. func (dc *Dependencies) GetUpdaterWithHooks() *updateref.UpdaterWithHooks { return dc.UpdaterWithHooks diff --git a/internal/gitaly/service/diff/raw_test.go b/internal/gitaly/service/diff/raw_test.go index e88d2210f..43ef42b73 100644 --- a/internal/gitaly/service/diff/raw_test.go +++ b/internal/gitaly/service/diff/raw_test.go @@ -10,7 +10,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage" "gitlab.com/gitlab-org/gitaly/v16/internal/structerr" "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper" - "gitlab.com/gitlab-org/gitaly/v16/internal/testhelper/testcfg" "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb" "gitlab.com/gitlab-org/gitaly/v16/streamio" ) @@ -20,7 +19,6 @@ func TestRawDiff_successful(t *testing.T) { ctx := testhelper.Context(t) cfg, client := setupDiffService(t) - testcfg.BuildGitalyGit2Go(t, cfg) repoProto, repoPath := gittest.CreateRepository(t, ctx, cfg) oldBlob := gittest.WriteBlob(t, cfg, repoPath, []byte("old\n")) diff --git a/internal/gitaly/service/diff/testhelper_test.go b/internal/gitaly/service/diff/testhelper_test.go index e19294090..4bde0b629 100644 --- a/internal/gitaly/service/diff/testhelper_test.go +++ b/internal/gitaly/service/diff/testhelper_test.go @@ -35,7 +35,6 @@ func setupDiffService(tb testing.TB, opt ...testserver.GitalyServerOpt) (config. deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/hook/testhelper_test.go b/internal/gitaly/service/hook/testhelper_test.go index 51404398e..95c2de53e 100644 --- a/internal/gitaly/service/hook/testhelper_test.go +++ b/internal/gitaly/service/hook/testhelper_test.go @@ -73,7 +73,6 @@ func runHooksServer(tb testing.TB, cfg config.Cfg, opts []serverOption, serverOp deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/objectpool/testhelper_test.go b/internal/gitaly/service/objectpool/testhelper_test.go index 48a5e2967..a20c28ed1 100644 --- a/internal/gitaly/service/objectpool/testhelper_test.go +++ b/internal/gitaly/service/objectpool/testhelper_test.go @@ -85,7 +85,6 @@ func runObjectPoolServer(t *testing.T, cfg config.Cfg, locator storage.Locator, deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/operations/server.go b/internal/gitaly/service/operations/server.go index 06386828a..b96e1ab18 100644 --- a/internal/gitaly/service/operations/server.go +++ b/internal/gitaly/service/operations/server.go @@ -8,7 +8,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v16/internal/git/catfile" "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo" "gitlab.com/gitlab-org/gitaly/v16/internal/git/quarantine" - "gitlab.com/gitlab-org/gitaly/v16/internal/git2go" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook/updateref" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage" @@ -20,15 +19,14 @@ import ( //nolint:revive // This is unintentionally missing documentation. type Server struct { gitalypb.UnimplementedOperationServiceServer - hookManager hook.Manager - txManager transaction.Manager - locator storage.Locator - conns *client.Pool - git2goExecutor *git2go.Executor - gitCmdFactory git.CommandFactory - catfileCache catfile.Cache - updater *updateref.UpdaterWithHooks - signingKey string + hookManager hook.Manager + txManager transaction.Manager + locator storage.Locator + conns *client.Pool + gitCmdFactory git.CommandFactory + catfileCache catfile.Cache + updater *updateref.UpdaterWithHooks + signingKey string } // NewServer creates a new instance of a grpc OperationServiceServer @@ -37,22 +35,20 @@ func NewServer( txManager transaction.Manager, locator storage.Locator, conns *client.Pool, - git2goExecutor *git2go.Executor, gitCmdFactory git.CommandFactory, catfileCache catfile.Cache, updater *updateref.UpdaterWithHooks, signingKey string, ) *Server { return &Server{ - hookManager: hookManager, - txManager: txManager, - locator: locator, - conns: conns, - git2goExecutor: git2goExecutor, - gitCmdFactory: gitCmdFactory, - catfileCache: catfileCache, - updater: updater, - signingKey: signingKey, + hookManager: hookManager, + txManager: txManager, + locator: locator, + conns: conns, + gitCmdFactory: gitCmdFactory, + catfileCache: catfileCache, + updater: updater, + signingKey: signingKey, } } diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go index a21c8b995..8d0a04074 100644 --- a/internal/gitaly/service/operations/testhelper_test.go +++ b/internal/gitaly/service/operations/testhelper_test.go @@ -41,7 +41,6 @@ func setupOperationsServiceWithCfg( tb testing.TB, ctx context.Context, cfg config.Cfg, options ...testserver.GitalyServerOpt, ) (context.Context, config.Cfg, gitalypb.OperationServiceClient) { testcfg.BuildGitalySSH(tb, cfg) - testcfg.BuildGitalyGit2Go(tb, cfg) testcfg.BuildGitalyHooks(tb, cfg) serverSocketPath := runOperationServiceServer(tb, cfg, options...) @@ -62,7 +61,6 @@ func setupOperationsService( cfg := testcfg.Build(tb) testcfg.BuildGitalySSH(tb, cfg) - testcfg.BuildGitalyGit2Go(tb, cfg) testcfg.BuildGitalyHooks(tb, cfg) serverSocketPath := runOperationServiceServer(tb, cfg, options...) @@ -86,7 +84,6 @@ func runOperationServiceServer(tb testing.TB, cfg config.Cfg, options ...testser deps.GetTxManager(), deps.GetLocator(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetUpdaterWithHooks(), @@ -108,7 +105,6 @@ func runOperationServiceServer(tb testing.TB, cfg config.Cfg, options ...testser deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/operations/user_create_branch_test.go b/internal/gitaly/service/operations/user_create_branch_test.go index 5fdd93f16..c6e8aa854 100644 --- a/internal/gitaly/service/operations/user_create_branch_test.go +++ b/internal/gitaly/service/operations/user_create_branch_test.go @@ -128,7 +128,6 @@ func TestUserCreateBranch_transactions(t *testing.T) { deps.GetTxManager(), deps.GetLocator(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetUpdaterWithHooks(), diff --git a/internal/gitaly/service/operations/user_delete_branch_test.go b/internal/gitaly/service/operations/user_delete_branch_test.go index 686778e0a..e71780551 100644 --- a/internal/gitaly/service/operations/user_delete_branch_test.go +++ b/internal/gitaly/service/operations/user_delete_branch_test.go @@ -451,7 +451,6 @@ func TestUserDeleteBranch_transaction(t *testing.T) { deps.GetTxManager(), deps.GetLocator(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetUpdaterWithHooks(), diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go index 48c12eb82..ccd53fb3c 100644 --- a/internal/gitaly/service/ref/delete_refs_test.go +++ b/internal/gitaly/service/ref/delete_refs_test.go @@ -119,7 +119,6 @@ func TestDeleteRefs_transaction(t *testing.T) { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go index d2f077855..a80dc7dcf 100644 --- a/internal/gitaly/service/ref/testhelper_test.go +++ b/internal/gitaly/service/ref/testhelper_test.go @@ -66,7 +66,6 @@ func runRefServiceServer(tb testing.TB, cfg config.Cfg) string { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/remote/testhelper_test.go b/internal/gitaly/service/remote/testhelper_test.go index 863d7f4d2..cf71f9860 100644 --- a/internal/gitaly/service/remote/testhelper_test.go +++ b/internal/gitaly/service/remote/testhelper_test.go @@ -39,7 +39,6 @@ func setupRemoteService(t *testing.T, ctx context.Context, opts ...testserver.Gi deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/remote/update_remote_mirror_test.go b/internal/gitaly/service/remote/update_remote_mirror_test.go index d295fbe6e..fdf94702c 100644 --- a/internal/gitaly/service/remote/update_remote_mirror_test.go +++ b/internal/gitaly/service/remote/update_remote_mirror_test.go @@ -587,7 +587,6 @@ func TestUpdateRemoteMirror(t *testing.T) { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/repository/server.go b/internal/gitaly/service/repository/server.go index aafcf2a9f..0e354b2d1 100644 --- a/internal/gitaly/service/repository/server.go +++ b/internal/gitaly/service/repository/server.go @@ -10,7 +10,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping" "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo" "gitlab.com/gitlab-org/gitaly/v16/internal/git/quarantine" - "gitlab.com/gitlab-org/gitaly/v16/internal/git2go" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/storage/counter" @@ -29,7 +28,6 @@ type server struct { cfg config.Cfg loggingCfg config.Logging catfileCache catfile.Cache - git2goExecutor *git2go.Executor housekeepingManager housekeeping.Manager backupSink backup.Sink backupLocator backup.Locator @@ -46,7 +44,6 @@ func NewServer( gitCmdFactory git.CommandFactory, catfileCache catfile.Cache, connsPool *client.Pool, - git2goExecutor *git2go.Executor, housekeepingManager housekeeping.Manager, backupSink backup.Sink, backupLocator backup.Locator, @@ -60,7 +57,6 @@ func NewServer( cfg: cfg, loggingCfg: cfg.Logging, catfileCache: catfileCache, - git2goExecutor: git2goExecutor, housekeepingManager: housekeepingManager, backupSink: backupSink, backupLocator: backupLocator, diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go index ec0bd90e5..ba57b32e7 100644 --- a/internal/gitaly/service/repository/testhelper_test.go +++ b/internal/gitaly/service/repository/testhelper_test.go @@ -63,7 +63,6 @@ func runRepositoryService(tb testing.TB, cfg config.Cfg, opts ...testserver.Gita deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/setup/register.go b/internal/gitaly/service/setup/register.go index 08a047a7b..b14298f1a 100644 --- a/internal/gitaly/service/setup/register.go +++ b/internal/gitaly/service/setup/register.go @@ -79,7 +79,6 @@ func RegisterAll(srv *grpc.Server, deps *service.Dependencies) { deps.GetTxManager(), deps.GetLocator(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetUpdaterWithHooks(), @@ -98,7 +97,6 @@ func RegisterAll(srv *grpc.Server, deps *service.Dependencies) { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/smarthttp/testhelper_test.go b/internal/gitaly/service/smarthttp/testhelper_test.go index 451043ea5..e765b020e 100644 --- a/internal/gitaly/service/smarthttp/testhelper_test.go +++ b/internal/gitaly/service/smarthttp/testhelper_test.go @@ -40,7 +40,6 @@ func startSmartHTTPServerWithOptions(t *testing.T, cfg config.Cfg, opts []Server deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/gitaly/service/ssh/testhelper_test.go b/internal/gitaly/service/ssh/testhelper_test.go index a1620b6f3..0d93a5e9f 100644 --- a/internal/gitaly/service/ssh/testhelper_test.go +++ b/internal/gitaly/service/ssh/testhelper_test.go @@ -49,7 +49,6 @@ func startSSHServerWithOptions(t *testing.T, cfg config.Cfg, opts []ServerOpt, s deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/praefect/info_service_test.go b/internal/praefect/info_service_test.go index d07ede6aa..bb2d2395e 100644 --- a/internal/praefect/info_service_test.go +++ b/internal/praefect/info_service_test.go @@ -44,7 +44,6 @@ func TestInfoService_RepositoryReplicas(t *testing.T) { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/praefect/verifier_test.go b/internal/praefect/verifier_test.go index b7319df48..a489a1e4a 100644 --- a/internal/praefect/verifier_test.go +++ b/internal/praefect/verifier_test.go @@ -484,7 +484,6 @@ func TestVerifier(t *testing.T) { deps.GetGitCmdFactory(), deps.GetCatfileCache(), deps.GetConnsPool(), - deps.GetGit2goExecutor(), deps.GetHousekeepingManager(), deps.GetBackupSink(), deps.GetBackupLocator(), diff --git a/internal/testhelper/configure.go b/internal/testhelper/configure.go index 7788788a3..6dc326057 100644 --- a/internal/testhelper/configure.go +++ b/internal/testhelper/configure.go @@ -111,7 +111,7 @@ func configure() (_ func(), returnedErr error) { } } - // We need to make sure that we're gitconfig-clean: neither Git nor libgit2 should pick up + // We need to make sure that we're gitconfig-clean: Git should not pick up // gitconfig files from anywhere but the repository itself in case they're configured to // ignore them. We set that configuration by default in our tests to have a known-good // environment. diff --git a/internal/testhelper/testcfg/binaries.go b/internal/testhelper/testcfg/binaries.go index c3d7265c7..8d403e8b0 100644 --- a/internal/testhelper/testcfg/binaries.go +++ b/internal/testhelper/testcfg/binaries.go @@ -18,16 +18,11 @@ import ( var buildOnceByName sync.Map -// BuildGitalyGPG builds the gitaly-git2go command and installs it into the binary directory. +// BuildGitalyGPG builds the gitaly-gpg command and installs it into the binary directory. func BuildGitalyGPG(tb testing.TB, cfg config.Cfg) string { return buildGitalyCommand(tb, cfg, "gitaly-gpg") } -// BuildGitalyGit2Go builds the gitaly-git2go command and installs it into the binary directory. -func BuildGitalyGit2Go(tb testing.TB, cfg config.Cfg) string { - return buildGitalyCommand(tb, cfg, "gitaly-git2go") -} - // BuildGitalyWrapper builds the gitaly-wrapper command and installs it into the binary directory. func BuildGitalyWrapper(tb testing.TB, cfg config.Cfg) string { return buildGitalyCommand(tb, cfg, "gitaly-wrapper") @@ -107,7 +102,7 @@ func BuildBinary(tb testing.TB, targetDir, sourcePath string) string { } buildTags := []string{ - "static", "system_libgit2", "gitaly_test", + "gitaly_test", } if os.Getenv("GITALY_TESTING_ENABLE_FIPS") != "" { buildTags = append(buildTags, "fips") diff --git a/internal/testhelper/testdata/home/.config/git/config b/internal/testhelper/testdata/home/.config/git/config index aef95e47e..e6dc1af91 100644 --- a/internal/testhelper/testdata/home/.config/git/config +++ b/internal/testhelper/testdata/home/.config/git/config @@ -1,4 +1,4 @@ -# We're trying to catch any instances of libgit2 or Git that pick up the +# We're trying to catch any instances of Git that pick up the # gitconfig even though they're told not to. If they do pick up this file # though, then they would fail to parse it and thus return an error, which we # can detect quite easily. diff --git a/internal/testhelper/testdata/home/.gitconfig b/internal/testhelper/testdata/home/.gitconfig index aef95e47e..e6dc1af91 100644 --- a/internal/testhelper/testdata/home/.gitconfig +++ b/internal/testhelper/testdata/home/.gitconfig @@ -1,4 +1,4 @@ -# We're trying to catch any instances of libgit2 or Git that pick up the +# We're trying to catch any instances of Git that pick up the # gitconfig even though they're told not to. If they do pick up this file # though, then they would fail to parse it and thus return an error, which we # can detect quite easily. diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go index 6baae7859..8cc44245c 100644 --- a/internal/testhelper/testserver/gitaly.go +++ b/internal/testhelper/testserver/gitaly.go @@ -18,7 +18,6 @@ import ( "gitlab.com/gitlab-org/gitaly/v16/internal/git/gittest" "gitlab.com/gitlab-org/gitaly/v16/internal/git/housekeeping" "gitlab.com/gitlab-org/gitaly/v16/internal/git/localrepo" - "gitlab.com/gitlab-org/gitaly/v16/internal/git2go" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/config/auth" "gitlab.com/gitlab-org/gitaly/v16/internal/gitaly/hook" @@ -268,7 +267,6 @@ type gitalyServerDeps struct { packObjectsLimiter limiter.Limiter limitHandler *limithandler.LimiterMiddleware repositoryCounter *counter.RepositoryCounter - git2goExecutor *git2go.Executor updaterWithHooks *updateref.UpdaterWithHooks housekeepingManager housekeeping.Manager backupSink backup.Sink @@ -343,10 +341,6 @@ func (gsd *gitalyServerDeps) createDependencies(tb testing.TB, cfg config.Cfg) * gsd.repositoryCounter = counter.NewRepositoryCounter(cfg.Storages) } - if gsd.git2goExecutor == nil { - gsd.git2goExecutor = git2go.NewExecutor(cfg, gsd.gitCmdFactory, gsd.locator, gsd.logger) - } - if gsd.updaterWithHooks == nil { gsd.updaterWithHooks = updateref.NewUpdaterWithHooks(cfg, gsd.locator, gsd.hookMgr, gsd.gitCmdFactory, gsd.catfileCache) } @@ -388,7 +382,6 @@ func (gsd *gitalyServerDeps) createDependencies(tb testing.TB, cfg config.Cfg) * PackObjectsLimiter: gsd.packObjectsLimiter, LimitHandler: gsd.limitHandler, RepositoryCounter: gsd.repositoryCounter, - Git2goExecutor: gsd.git2goExecutor, UpdaterWithHooks: gsd.updaterWithHooks, HousekeepingManager: gsd.housekeepingManager, PartitionManager: partitionManager, |