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>2021-03-09 16:08:34 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-03-11 10:14:39 +0300
commited3ba390c7d31580a8cea9d9ae3c5d019fd39fdd (patch)
treefe1c3796312b30c5f5c7bbd11868c8f20ec5d2cc
parentdb74b76121b84060c79a82f78f83444e167bdb73 (diff)
localrepo: Convert `FetchOpts` to accept command options
The global options are about to go away in favor of using command options. This commit thus converts `FetchOpts` to accept a set of command options instead of global options and converts callers accordingly.
-rw-r--r--internal/git/localrepo/remote.go17
-rw-r--r--internal/git/localrepo/remote_test.go4
-rw-r--r--internal/gitaly/service/repository/fetch_remote.go8
3 files changed, 19 insertions, 10 deletions
diff --git a/internal/git/localrepo/remote.go b/internal/git/localrepo/remote.go
index 5e09fc47f..f36b4c621 100644
--- a/internal/git/localrepo/remote.go
+++ b/internal/git/localrepo/remote.go
@@ -194,8 +194,8 @@ var (
type FetchOpts struct {
// Env is a list of env vars to pass to the cmd.
Env []string
- // Global is a list of global flags to use with 'git' command.
- Global []git.GlobalOption
+ // CommandOptions is a list of options to use with 'git' command.
+ CommandOptions []git.CmdOpt
// Prune if set fetch removes any remote-tracking references that no longer exist on the remote.
// https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---prune
Prune bool
@@ -222,15 +222,20 @@ func (repo *Repo) FetchRemote(ctx context.Context, remoteName string, opts Fetch
return err
}
- cmd, err := repo.gitCmdFactory.New(ctx, repo, opts.Global,
+ commandOptions := []git.CmdOpt{
+ git.WithEnv(opts.Env...),
+ git.WithStderr(opts.Stderr),
+ git.WithDisabledHooks(),
+ }
+ commandOptions = append(commandOptions, opts.CommandOptions...)
+
+ cmd, err := repo.gitCmdFactory.New(ctx, repo, nil,
git.SubCmd{
Name: "fetch",
Flags: opts.buildFlags(),
Args: []string{remoteName},
},
- git.WithEnv(opts.Env...),
- git.WithStderr(opts.Stderr),
- git.WithDisabledHooks(),
+ commandOptions...,
)
if err != nil {
return err
diff --git a/internal/git/localrepo/remote_test.go b/internal/git/localrepo/remote_test.go
index a082dff01..009cf205a 100644
--- a/internal/git/localrepo/remote_test.go
+++ b/internal/git/localrepo/remote_test.go
@@ -394,7 +394,9 @@ func TestRepo_FetchRemote(t *testing.T) {
ctx,
"source",
FetchOpts{
- Global: []git.GlobalOption{git.ConfigPair{Key: "fetch.prune", Value: "true"}},
+ CommandOptions: []git.CmdOpt{
+ git.WithConfig(git.ConfigPair{Key: "fetch.prune", Value: "true"}),
+ },
}),
)
diff --git a/internal/gitaly/service/repository/fetch_remote.go b/internal/gitaly/service/repository/fetch_remote.go
index aced28701..a8627e0ea 100644
--- a/internal/gitaly/service/repository/fetch_remote.go
+++ b/internal/gitaly/service/repository/fetch_remote.go
@@ -87,7 +87,9 @@ func (s *server) FetchRemote(ctx context.Context, req *gitalypb.FetchRemoteReque
}(ctx)
for _, refspec := range refspecs {
- opts.Global = append(opts.Global, git.ConfigPair{Key: "remote." + remoteName + ".fetch", Value: refspec})
+ opts.CommandOptions = append(opts.CommandOptions,
+ git.WithConfig(git.ConfigPair{Key: "remote." + remoteName + ".fetch", Value: refspec}),
+ )
}
if params.GetHttpAuthorizationHeader() != "" {
@@ -147,8 +149,8 @@ func (s *server) FetchRemote(ctx context.Context, req *gitalypb.FetchRemoteReque
defer cancel()
}
- opts.Global = append(opts.Global,
- git.ConfigPair{Key: "http.followRedirects", Value: "false"},
+ opts.CommandOptions = append(opts.CommandOptions,
+ git.WithConfig(git.ConfigPair{Key: "http.followRedirects", Value: "false"}),
)
if err := repo.FetchRemote(ctx, remoteName, opts); err != nil {