diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-26 12:09:10 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-01-26 13:59:23 +0300 |
commit | d1bac7bc31c64c04ec67855c8f2c740275d9bc44 (patch) | |
tree | e7a7aba07417c890ad0088008764db9b61f3d85f | |
parent | bd7967b11961b088292061e5ea10443259d60876 (diff) |
git: Use LocalRepository.command for config and remotes
Because both LocalRepositoryConfig and LocalRepositoryRemote didn't have
a reference to LocalRepository but only to the `repository.GitRepo`
interface, they couldn't use `LocalRepository.command()`. Now that this
has been changed, let's convert both implementations to use this
function instead of `git.NewCommand()`.
-rw-r--r-- | internal/git/localrepo_config.go | 6 | ||||
-rw-r--r-- | internal/git/localrepo_remote.go | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/internal/git/localrepo_config.go b/internal/git/localrepo_config.go index a8656b7b9..fea2e4fed 100644 --- a/internal/git/localrepo_config.go +++ b/internal/git/localrepo_config.go @@ -23,7 +23,7 @@ func (cfg LocalRepositoryConfig) Add(ctx context.Context, name, value string, op return err } - cmd, err := NewCommand(ctx, cfg.repo, nil, SubCmd{ + cmd, err := cfg.repo.command(ctx, nil, SubCmd{ Name: "config", Flags: append(opts.buildFlags(), Flag{Name: "--add"}), Args: []string{name, value}, @@ -65,7 +65,7 @@ func (cfg LocalRepositoryConfig) GetRegexp(ctx context.Context, nameRegexp strin func (cfg LocalRepositoryConfig) getRegexp(ctx context.Context, nameRegexp string, opts ConfigGetRegexpOpts) ([]byte, error) { var stderr bytes.Buffer - cmd, err := NewCommand(ctx, cfg.repo, nil, + cmd, err := cfg.repo.command(ctx, nil, SubCmd{ Name: "config", // '--null' is used to support proper parsing of the multiline config values @@ -151,7 +151,7 @@ func (cfg LocalRepositoryConfig) parseConfig(data []byte, opts ConfigGetRegexpOp // Unset unsets the given config entry. func (cfg LocalRepositoryConfig) Unset(ctx context.Context, name string, opts ConfigUnsetOpts) error { - cmd, err := NewCommand(ctx, cfg.repo, nil, SubCmd{ + cmd, err := cfg.repo.command(ctx, nil, SubCmd{ Name: "config", Flags: opts.buildFlags(), Args: []string{name}, diff --git a/internal/git/localrepo_remote.go b/internal/git/localrepo_remote.go index ef2894dcc..eab81928c 100644 --- a/internal/git/localrepo_remote.go +++ b/internal/git/localrepo_remote.go @@ -28,7 +28,7 @@ func (remote LocalRepositoryRemote) Add(ctx context.Context, name, url string, o } stderr := bytes.Buffer{} - cmd, err := NewCommand(ctx, remote.repo, nil, + cmd, err := remote.repo.command(ctx, nil, SubSubCmd{ Name: "remote", Action: "add", @@ -68,7 +68,7 @@ func (remote LocalRepositoryRemote) Remove(ctx context.Context, name string) err } var stderr bytes.Buffer - cmd, err := NewCommand(ctx, remote.repo, nil, + cmd, err := remote.repo.command(ctx, nil, SubSubCmd{ Name: "remote", Action: "remove", @@ -111,7 +111,7 @@ func (remote LocalRepositoryRemote) SetURL(ctx context.Context, name, url string } var stderr bytes.Buffer - cmd, err := NewCommand(ctx, remote.repo, nil, + cmd, err := remote.repo.command(ctx, nil, SubSubCmd{ Name: "remote", Action: "set-url", |