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:
authorPavlo Strokov <pstrokov@gitlab.com>2021-01-20 13:33:25 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2021-01-21 17:06:20 +0300
commit0ea0a01ce34fdd2fa3ea584beaa400fa3dce5498 (patch)
treeeb140160c2e9a4b26ffb325bb144a0a98c08e620
parent00355f80cf9a280a7cd2c445bda32db2af6a1d60 (diff)
Rename of the CommandFactory as it is needed as an interface
We need to introduce an abstraction that will be responsible for the git commands creation and we need CommandFactory name for the interface. And as the only impl now depends on the exec package it is renamed after it. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r--internal/git/command.go6
-rw-r--r--internal/git/command_factory.go14
-rw-r--r--internal/git/repository.go4
3 files changed, 12 insertions, 12 deletions
diff --git a/internal/git/command.go b/internal/git/command.go
index 998cc34df..fed3657d1 100644
--- a/internal/git/command.go
+++ b/internal/git/command.go
@@ -332,7 +332,7 @@ var (
// NewCommand creates a command.Command with the given args and Repository. It
// validates the arguments in the command before executing.
func NewCommand(ctx context.Context, repo repository.GitRepo, globals []GlobalOption, sc Cmd, opts ...CmdOpt) (*command.Command, error) {
- return NewCommandFactory(config.Config).newCommand(ctx, repo, "", globals, sc, opts...)
+ return NewExecCommandFactory(config.Config).newCommand(ctx, repo, "", globals, sc, opts...)
}
// NewCommandWithoutRepo creates a command.Command with the given args. It is not
@@ -340,7 +340,7 @@ func NewCommand(ctx context.Context, repo repository.GitRepo, globals []GlobalOp
// commands which do not require a git repository or which accept a repository
// path as parameter like e.g. git-upload-pack(1).
func NewCommandWithoutRepo(ctx context.Context, globals []GlobalOption, sc Cmd, opts ...CmdOpt) (*command.Command, error) {
- return NewCommandFactory(config.Config).newCommand(ctx, nil, "", globals, sc, opts...)
+ return NewExecCommandFactory(config.Config).newCommand(ctx, nil, "", globals, sc, opts...)
}
// NewCommandWithDir creates a new command.Command whose working directory is set
@@ -351,5 +351,5 @@ func NewCommandWithDir(ctx context.Context, dir string, globals []GlobalOption,
return nil, errors.New("no 'dir' provided")
}
- return NewCommandFactory(config.Config).newCommand(ctx, nil, dir, globals, sc, opts...)
+ return NewExecCommandFactory(config.Config).newCommand(ctx, nil, dir, globals, sc, opts...)
}
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go
index f51b5af95..80ce659ac 100644
--- a/internal/git/command_factory.go
+++ b/internal/git/command_factory.go
@@ -13,25 +13,25 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/storage"
)
-// CommandFactory knows how to properly construct different types of commands.
-type CommandFactory struct {
+// ExecCommandFactory knows how to properly construct different types of commands.
+type ExecCommandFactory struct {
locator storage.Locator
cfg config.Cfg
cgroupsManager cgroups.Manager
}
-// NewCommandFactory returns a new instance of initialized CommandFactory.
+// NewExecCommandFactory returns a new instance of initialized ExecCommandFactory.
// Current implementation relies on the global var 'config.Config' and a single type of 'Locator' we currently have.
// This dependency will be removed on the next iterations in scope of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-func NewCommandFactory(cfg config.Cfg) *CommandFactory {
- return &CommandFactory{
+func NewExecCommandFactory(cfg config.Cfg) *ExecCommandFactory {
+ return &ExecCommandFactory{
cfg: cfg,
locator: config.NewLocator(cfg),
cgroupsManager: cgroups.NewManager(cfg.Cgroups),
}
}
-func (cf *CommandFactory) gitPath() string {
+func (cf *ExecCommandFactory) gitPath() string {
return cf.cfg.Git.BinPath
}
@@ -40,7 +40,7 @@ func (cf *CommandFactory) gitPath() string {
// context of that repository. Note that this sets up arguments and environment
// variables for git, but doesn't run in the directory itself. If a directory
// is given, then the command will be run in that directory.
-func (cf *CommandFactory) newCommand(ctx context.Context, repo repository.GitRepo, dir string, globals []GlobalOption, sc Cmd, opts ...CmdOpt) (*command.Command, error) {
+func (cf *ExecCommandFactory) newCommand(ctx context.Context, repo repository.GitRepo, dir string, globals []GlobalOption, sc Cmd, opts ...CmdOpt) (*command.Command, error) {
cc := &cmdCfg{}
if err := handleOpts(ctx, sc, cc, opts); err != nil {
diff --git a/internal/git/repository.go b/internal/git/repository.go
index 7a99aa9c3..b03ac61c8 100644
--- a/internal/git/repository.go
+++ b/internal/git/repository.go
@@ -115,7 +115,7 @@ type Repository interface {
// LocalRepository represents a local Git repository.
type LocalRepository struct {
repo repository.GitRepo
- commandFactory *CommandFactory
+ commandFactory *ExecCommandFactory
cfg config.Cfg
}
@@ -124,7 +124,7 @@ func NewRepository(repo repository.GitRepo, cfg config.Cfg) *LocalRepository {
return &LocalRepository{
repo: repo,
cfg: cfg,
- commandFactory: NewCommandFactory(cfg),
+ commandFactory: NewExecCommandFactory(cfg),
}
}