Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-04-12 14:07:30 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-04-12 14:08:15 +0300
commit52b6be49de233fbb8382e30e9d14f03818b97d6d (patch)
tree10c8fd00a05db72517a0113b23c15e0b4c3ee9f8
parentb8190668d147784e8be4a379b33f691363e08a0f (diff)
git: Remove sidecar Git configuration from command factory
Remove unused functionality to compute the Git configuration as used by our sidecar in the Git command factory.
-rw-r--r--internal/git/command_factory.go52
-rw-r--r--internal/git/command_factory_test.go22
-rw-r--r--internal/git/gittest/intercepting_command_factory.go6
3 files changed, 0 insertions, 80 deletions
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go
index 6bef294a2..a637d96b4 100644
--- a/internal/git/command_factory.go
+++ b/internal/git/command_factory.go
@@ -38,11 +38,6 @@ type CommandFactory interface {
HooksPath(context.Context) string
// GitVersion returns the Git version used by the command factory.
GitVersion(context.Context) (Version, error)
-
- // SidecarGitConfiguration returns the Git configuration is it should be used by the Ruby
- // sidecar. This is a design wart and shouldn't ever be used outside of the context of the
- // sidecar.
- SidecarGitConfiguration(context.Context) ([]ConfigPair, error)
}
type execCommandFactoryConfig struct {
@@ -611,53 +606,6 @@ func (cf *ExecCommandFactory) GlobalConfiguration(ctx context.Context) ([]Config
return config, nil
}
-// SidecarGitConfiguration assembles the Git configuration as required by the Ruby sidecar. This
-// includes global configuration, command-specific configuration for all commands executed in the
-// sidecar, as well as configuration that was configured by the administrator in Gitaly's config.
-//
-// This function should not be used for anything else but the Ruby sidecar.
-func (cf *ExecCommandFactory) SidecarGitConfiguration(ctx context.Context) ([]ConfigPair, error) {
- // Collect the global configuration that is specific to the current Git version...
- globalConfig, err := cf.GlobalConfiguration(ctx)
- if err != nil {
- return nil, fmt.Errorf("getting global config: %w", err)
- }
-
- var options []GlobalOption
- for _, configPair := range globalConfig {
- options = append(options, configPair)
- }
-
- // ... as well as all configuration that exists for specific Git subcommands. The sidecar
- // only executes git-update-ref(1) nowadays, and this set of commands is not expected to
- // grow anymore. So while really intimate with how the sidecar does this, it is good enough
- // until we finally remove it.
- options = append(options, commandDescriptions["update-ref"].opts...)
-
- // Convert the `GlobalOption`s into `ConfigPair`s.
- configPairs := make([]ConfigPair, 0, len(options)+len(cf.cfg.Git.Config))
- for _, option := range options {
- configPair, ok := option.(ConfigPair)
- if !ok {
- continue
- }
-
- configPairs = append(configPairs, configPair)
- }
-
- // Lastly, we also apply the Git configuration as set by the administrator in Gitaly's
- // config. Note that we do not check for conflicts here: administrators should be able to
- // override whatever is configured by Gitaly.
- for _, configEntry := range cf.cfg.Git.Config {
- configPairs = append(configPairs, ConfigPair{
- Key: configEntry.Key,
- Value: configEntry.Value,
- })
- }
-
- return configPairs, nil
-}
-
func (cf *ExecCommandFactory) trace2Finalizer(manager *trace2.Manager) func(context.Context, *command.Command) {
return func(ctx context.Context, cmd *command.Command) {
manager.Finish(ctx)
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go
index 677221d48..955ac513d 100644
--- a/internal/git/command_factory_test.go
+++ b/internal/git/command_factory_test.go
@@ -654,28 +654,6 @@ func TestExecCommandFactory_config(t *testing.T) {
require.Equal(t, expectedEnv, strings.Split(strings.TrimSpace(stdout.String()), "\n"))
}
-func TestExecCommandFactory_SidecarGitConfiguration(t *testing.T) {
- t.Parallel()
-
- ctx := testhelper.Context(t)
- cfg := testcfg.Build(t)
-
- cfg.Git.Config = []config.GitConfig{
- {Key: "custom.key", Value: "injected"},
- }
-
- configPairs, err := gittest.NewCommandFactory(t, cfg).SidecarGitConfiguration(ctx)
- require.NoError(t, err)
- require.Equal(t, []git.ConfigPair{
- {Key: "gc.auto", Value: "0"},
- {Key: "core.autocrlf", Value: "input"},
- {Key: "core.useReplaceRefs", Value: "false"},
- {Key: "core.fsync", Value: "objects,derived-metadata,reference"},
- {Key: "core.fsyncMethod", Value: "fsync"},
- {Key: "custom.key", Value: "injected"},
- }, configPairs)
-}
-
// TestFsckConfiguration tests the hardcoded configuration of the
// git fsck subcommand generated through the command factory.
func TestFsckConfiguration(t *testing.T) {
diff --git a/internal/git/gittest/intercepting_command_factory.go b/internal/git/gittest/intercepting_command_factory.go
index 8f229927c..cda216b4e 100644
--- a/internal/git/gittest/intercepting_command_factory.go
+++ b/internal/git/gittest/intercepting_command_factory.go
@@ -141,9 +141,3 @@ func (f *InterceptingCommandFactory) GitVersion(ctx context.Context) (git.Versio
}
return f.realCommandFactory.GitVersion(ctx)
}
-
-// SidecarGitConfiguration returns the Ruby sidecar Git configuration as computed by the actual Git
-// command factory.
-func (f *InterceptingCommandFactory) SidecarGitConfiguration(ctx context.Context) ([]git.ConfigPair, error) {
- return f.interceptingCommandFactory.SidecarGitConfiguration(ctx)
-}