diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-07-19 10:01:19 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-07-20 09:48:15 +0300 |
commit | f3906a724a2c04b852534493de923a448912c330 (patch) | |
tree | fbbaf1dce6604c7069d858dd61bf830b1783143c | |
parent | 9ceb56766a1b96b8fb4bef5bd3660dfae778a3b4 (diff) |
git2go: Pass binary path to runWithGob
We're about to migrate all subcommands of gitaly-git2go to be
implemented on top of the `Executor` structure. Given that this
structure only has paths to binaries instead of the complete config,
this would be hard to do for those which use `runWithGob()`, which
currently requires a complete `config.Cfg` as input.
Convert `runWithGob()` to require the path to the binary, only.
Eventually, this parameter will go away anyway given that we'll make it
a receiver function of the `Executor`, but it helps us to refactor the
code one by one while that's not yet the case.
-rw-r--r-- | internal/git2go/cherry_pick.go | 2 | ||||
-rw-r--r-- | internal/git2go/gob.go | 5 | ||||
-rw-r--r-- | internal/git2go/rebase.go | 2 | ||||
-rw-r--r-- | internal/git2go/revert.go | 2 |
4 files changed, 5 insertions, 6 deletions
diff --git a/internal/git2go/cherry_pick.go b/internal/git2go/cherry_pick.go index 2434b4ea1..8e6b43936 100644 --- a/internal/git2go/cherry_pick.go +++ b/internal/git2go/cherry_pick.go @@ -30,5 +30,5 @@ type CherryPickCommand struct { // Run performs a cherry pick via gitaly-git2go. func (m CherryPickCommand) Run(ctx context.Context, cfg config.Cfg) (git.ObjectID, error) { - return runWithGob(ctx, cfg, "cherry-pick", m) + return runWithGob(ctx, BinaryPath(cfg.BinDir), "cherry-pick", m) } diff --git a/internal/git2go/gob.go b/internal/git2go/gob.go index abb20dd4c..c6a53875c 100644 --- a/internal/git2go/gob.go +++ b/internal/git2go/gob.go @@ -9,7 +9,6 @@ import ( "reflect" "gitlab.com/gitlab-org/gitaly/v14/internal/git" - "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config" ) func init() { @@ -96,13 +95,13 @@ func SerializableError(err error) error { // runWithGob runs the specified gitaly-git2go cmd with the request gob-encoded // as input and returns the commit ID as string or an error. -func runWithGob(ctx context.Context, cfg config.Cfg, cmd string, request interface{}) (git.ObjectID, error) { +func runWithGob(ctx context.Context, binaryPath string, cmd string, request interface{}) (git.ObjectID, error) { input := &bytes.Buffer{} if err := gob.NewEncoder(input).Encode(request); err != nil { return "", fmt.Errorf("%s: %w", cmd, err) } - output, err := run(ctx, BinaryPath(cfg.BinDir), input, cmd) + output, err := run(ctx, binaryPath, input, cmd) if err != nil { return "", fmt.Errorf("%s: %w", cmd, err) } diff --git a/internal/git2go/rebase.go b/internal/git2go/rebase.go index a54885b14..ffa93e269 100644 --- a/internal/git2go/rebase.go +++ b/internal/git2go/rebase.go @@ -21,5 +21,5 @@ type RebaseCommand struct { // Run performs the rebase via gitaly-git2go func (r RebaseCommand) Run(ctx context.Context, cfg config.Cfg) (git.ObjectID, error) { - return runWithGob(ctx, cfg, "rebase", r) + return runWithGob(ctx, BinaryPath(cfg.BinDir), "rebase", r) } diff --git a/internal/git2go/revert.go b/internal/git2go/revert.go index 67e0a91aa..b495422e5 100644 --- a/internal/git2go/revert.go +++ b/internal/git2go/revert.go @@ -28,5 +28,5 @@ type RevertCommand struct { } func (r RevertCommand) Run(ctx context.Context, cfg config.Cfg) (git.ObjectID, error) { - return runWithGob(ctx, cfg, "revert", r) + return runWithGob(ctx, BinaryPath(cfg.BinDir), "revert", r) } |