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 15:10:08 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-03-11 10:14:39 +0300
commit29572a55f466f6185c5f64ff62d43e844b7522af (patch)
tree294e536bc59761d65cb0079b345fd7c073f5d45b
parenta5badbeeb2d1b27cf0dc614e404580d632537c5a (diff)
git: Drop `GlobalOption`s from `NewWithDir()`
The `GlobalOption`s argument of the command factory's `NewWithDir()` function isn't used anymore. Let's drop it.
-rw-r--r--internal/git/command_factory.go6
-rw-r--r--internal/git/command_factory_test.go6
-rw-r--r--internal/gitaly/service/operations/squash.go12
-rw-r--r--internal/gitaly/service/repository/create_from_bundle.go2
4 files changed, 13 insertions, 13 deletions
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go
index 793f28c44..8eb040182 100644
--- a/internal/git/command_factory.go
+++ b/internal/git/command_factory.go
@@ -39,7 +39,7 @@ type CommandFactory interface {
// NewWithoutRepo creates a command without a target repository.
NewWithoutRepo(ctx context.Context, globals []GlobalOption, sc Cmd, opts ...CmdOpt) (*command.Command, error)
// NewWithDir creates a command without a target repository that would be executed in dir directory.
- NewWithDir(ctx context.Context, dir string, globals []GlobalOption, sc Cmd, opts ...CmdOpt) (*command.Command, error)
+ NewWithDir(ctx context.Context, dir string, sc Cmd, opts ...CmdOpt) (*command.Command, error)
}
// ExecCommandFactory knows how to properly construct different types of commands.
@@ -71,12 +71,12 @@ func (cf *ExecCommandFactory) NewWithoutRepo(ctx context.Context, globals []Glob
// NewWithDir creates a new command.Command whose working directory is set
// to dir. Arguments are validated before the command is being run. It is
// invalid to use an empty directory.
-func (cf *ExecCommandFactory) NewWithDir(ctx context.Context, dir string, globals []GlobalOption, sc Cmd, opts ...CmdOpt) (*command.Command, error) {
+func (cf *ExecCommandFactory) NewWithDir(ctx context.Context, dir string, sc Cmd, opts ...CmdOpt) (*command.Command, error) {
if dir == "" {
return nil, errors.New("no 'dir' provided")
}
- return cf.newCommand(ctx, nil, dir, globals, sc, opts...)
+ return cf.newCommand(ctx, nil, dir, nil, sc, opts...)
}
func (cf *ExecCommandFactory) gitPath() string {
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go
index 5c4a4dcef..4e3df2850 100644
--- a/internal/git/command_factory_test.go
+++ b/internal/git/command_factory_test.go
@@ -58,7 +58,7 @@ func TestExecCommandFactory_NewWithDir(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- _, err := gitCmdFactory.NewWithDir(ctx, "", nil, nil, nil)
+ _, err := gitCmdFactory.NewWithDir(ctx, "", nil, nil)
require.Error(t, err)
require.Contains(t, err.Error(), "no 'dir' provided")
})
@@ -75,7 +75,7 @@ func TestExecCommandFactory_NewWithDir(t *testing.T) {
defer cancel()
var stderr bytes.Buffer
- cmd, err := gitCmdFactory.NewWithDir(ctx, repoPath, nil, git.SubCmd{
+ cmd, err := gitCmdFactory.NewWithDir(ctx, repoPath, git.SubCmd{
Name: "rev-parse",
Args: []string{"master"},
}, git.WithStderr(&stderr))
@@ -94,7 +94,7 @@ func TestExecCommandFactory_NewWithDir(t *testing.T) {
defer cancel()
var stderr bytes.Buffer
- _, err := gitCmdFactory.NewWithDir(ctx, "non-existing-dir", nil, git.SubCmd{
+ _, err := gitCmdFactory.NewWithDir(ctx, "non-existing-dir", git.SubCmd{
Name: "rev-parse",
Args: []string{"master"},
}, git.WithStderr(&stderr))
diff --git a/internal/gitaly/service/operations/squash.go b/internal/gitaly/service/operations/squash.go
index 74a376560..4a42de06f 100644
--- a/internal/gitaly/service/operations/squash.go
+++ b/internal/gitaly/service/operations/squash.go
@@ -131,7 +131,7 @@ func (s *Server) userSquash(ctx context.Context, req *gitalypb.UserSquashRequest
func (s *Server) diffFiles(ctx context.Context, env []string, repoPath string, req *gitalypb.UserSquashRequest) ([]byte, error) {
var stdout, stderr bytes.Buffer
- cmd, err := s.gitCmdFactory.NewWithDir(ctx, repoPath, nil,
+ cmd, err := s.gitCmdFactory.NewWithDir(ctx, repoPath,
git.SubCmd{
Name: "diff",
Flags: []git.Option{git.Flag{Name: "--name-only"}, git.Flag{Name: "--diff-filter=ar"}, git.Flag{Name: "--binary"}},
@@ -209,7 +209,7 @@ func (s *Server) userSquashWithDiffInFiles(ctx context.Context, req *gitalypb.Us
func (s *Server) checkout(ctx context.Context, repo *gitalypb.Repository, worktreePath string, req *gitalypb.UserSquashRequest) error {
var stderr bytes.Buffer
- checkoutCmd, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath, nil,
+ checkoutCmd, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath,
git.SubCmd{
Name: "checkout",
Flags: []git.Option{git.Flag{Name: "--detach"}},
@@ -235,7 +235,7 @@ func (s *Server) checkout(ctx context.Context, repo *gitalypb.Repository, worktr
func (s *Server) revParseGitDir(ctx context.Context, worktreePath string) (string, error) {
var stdout, stderr bytes.Buffer
- cmd, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath, nil,
+ cmd, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath,
git.SubCmd{
Name: "rev-parse",
Flags: []git.Option{git.Flag{Name: "--git-dir"}},
@@ -354,7 +354,7 @@ func (s *Server) applyDiff(ctx context.Context, repo *gitalypb.Repository, req *
}
var applyStderr bytes.Buffer
- cmdApply, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath, nil,
+ cmdApply, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath,
git.SubCmd{
Name: "apply",
Flags: []git.Option{
@@ -401,7 +401,7 @@ func (s *Server) applyDiff(ctx context.Context, repo *gitalypb.Repository, req *
)
var commitStderr bytes.Buffer
- cmdCommit, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath, nil, git.SubCmd{
+ cmdCommit, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath, git.SubCmd{
Name: "commit",
Flags: []git.Option{
git.Flag{Name: "--no-verify"},
@@ -418,7 +418,7 @@ func (s *Server) applyDiff(ctx context.Context, repo *gitalypb.Repository, req *
}
var revParseStdout, revParseStderr bytes.Buffer
- revParseCmd, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath, nil, git.SubCmd{
+ revParseCmd, err := s.gitCmdFactory.NewWithDir(ctx, worktreePath, git.SubCmd{
Name: "rev-parse",
Flags: []git.Option{
git.Flag{Name: "--quiet"},
diff --git a/internal/gitaly/service/repository/create_from_bundle.go b/internal/gitaly/service/repository/create_from_bundle.go
index 129b1bd58..12a74a857 100644
--- a/internal/gitaly/service/repository/create_from_bundle.go
+++ b/internal/gitaly/service/repository/create_from_bundle.go
@@ -94,7 +94,7 @@ func (s *server) CreateRepositoryFromBundle(stream gitalypb.RepositoryService_Cr
// We do a fetch to get all refs including keep-around refs
stderr.Reset()
- cmd, err = s.gitCmdFactory.NewWithDir(ctx, repoPath, nil,
+ cmd, err = s.gitCmdFactory.NewWithDir(ctx, repoPath,
git.SubCmd{
Name: "fetch",
Flags: []git.Option{git.Flag{Name: "--quiet"}},