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:
-rw-r--r--cmd/gitaly-git2go/submodule_test.go2
-rw-r--r--internal/git/localrepo/config_test.go8
-rw-r--r--internal/git/localrepo/objects.go2
-rw-r--r--internal/git/localrepo/objects_test.go8
-rw-r--r--internal/git/localrepo/refs_test.go14
-rw-r--r--internal/git/localrepo/remote_test.go22
-rw-r--r--internal/git/localrepo/repo.go14
-rw-r--r--internal/git/localrepo/repo_test.go2
-rw-r--r--internal/git/updateref/updateref_test.go22
-rw-r--r--internal/git2go/apply_test.go3
-rw-r--r--internal/git2go/commit_test.go3
-rw-r--r--internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go2
-rw-r--r--internal/gitaly/service/commit/find_commit.go2
-rw-r--r--internal/gitaly/service/commit/find_commit_test.go2
-rw-r--r--internal/gitaly/service/commit/list_files.go2
-rw-r--r--internal/gitaly/service/commit/stats.go2
-rw-r--r--internal/gitaly/service/conflicts/list_conflict_files.go2
-rw-r--r--internal/gitaly/service/conflicts/list_conflict_files_test.go2
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts.go4
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts_test.go6
-rw-r--r--internal/gitaly/service/diff/find_changed_paths.go2
-rw-r--r--internal/gitaly/service/objectpool/link_test.go2
-rw-r--r--internal/gitaly/service/operations/apply_patch_test.go4
-rw-r--r--internal/gitaly/service/operations/branches.go4
-rw-r--r--internal/gitaly/service/operations/branches_test.go4
-rw-r--r--internal/gitaly/service/operations/cherry_pick_test.go16
-rw-r--r--internal/gitaly/service/operations/commit_files.go4
-rw-r--r--internal/gitaly/service/operations/commit_files_test.go16
-rw-r--r--internal/gitaly/service/operations/merge.go6
-rw-r--r--internal/gitaly/service/operations/merge_test.go14
-rw-r--r--internal/gitaly/service/operations/rebase_test.go12
-rw-r--r--internal/gitaly/service/operations/revert.go4
-rw-r--r--internal/gitaly/service/operations/revert_test.go22
-rw-r--r--internal/gitaly/service/operations/squash_test.go8
-rw-r--r--internal/gitaly/service/operations/submodules.go2
-rw-r--r--internal/gitaly/service/operations/submodules_test.go4
-rw-r--r--internal/gitaly/service/operations/tags.go4
-rw-r--r--internal/gitaly/service/operations/tags_test.go8
-rw-r--r--internal/gitaly/service/operations/update_branches_test.go6
-rw-r--r--internal/gitaly/service/operations/update_with_hooks_test.go4
-rw-r--r--internal/gitaly/service/ref/branches.go2
-rw-r--r--internal/gitaly/service/ref/branches_test.go2
-rw-r--r--internal/gitaly/service/ref/delete_refs.go2
-rw-r--r--internal/gitaly/service/ref/delete_refs_test.go3
-rw-r--r--internal/gitaly/service/ref/pack_refs_test.go2
-rw-r--r--internal/gitaly/service/ref/refs_test.go6
-rw-r--r--internal/gitaly/service/ref/remote_branches_test.go2
-rw-r--r--internal/gitaly/service/repository/create_from_bundle_test.go3
-rw-r--r--internal/gitaly/service/repository/fetch.go2
-rw-r--r--internal/gitaly/service/repository/fetch_remote.go2
-rw-r--r--internal/gitaly/service/repository/fetch_remote_test.go8
-rw-r--r--internal/gitaly/service/repository/fetch_test.go4
-rw-r--r--internal/gitaly/service/repository/gc_test.go2
-rw-r--r--internal/gitaly/service/repository/midx_test.go2
-rw-r--r--internal/gitaly/service/repository/repository.go2
-rw-r--r--internal/gitaly/service/wiki/delete_page_test.go2
-rw-r--r--internal/gitaly/service/wiki/testhelper_test.go2
-rw-r--r--internal/gitaly/service/wiki/update_page_test.go2
-rw-r--r--internal/gitaly/service/wiki/write_page_test.go2
59 files changed, 166 insertions, 156 deletions
diff --git a/cmd/gitaly-git2go/submodule_test.go b/cmd/gitaly-git2go/submodule_test.go
index 26357598f..73a4230da 100644
--- a/cmd/gitaly-git2go/submodule_test.go
+++ b/cmd/gitaly-git2go/submodule_test.go
@@ -88,7 +88,7 @@ func TestSubmodule(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
testRepo, testRepoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(testRepo, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
tc.command.Repository = testRepoPath
diff --git a/internal/git/localrepo/config_test.go b/internal/git/localrepo/config_test.go
index 9d0f55980..7a10aaf19 100644
--- a/internal/git/localrepo/config_test.go
+++ b/internal/git/localrepo/config_test.go
@@ -18,7 +18,7 @@ func TestRepo_Config(t *testing.T) {
bareRepo, _, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := New(bareRepo, config.Config)
+ repo := New(nil, bareRepo, config.Cfg{})
require.Equal(t, Config{repo: repo}, repo.Config())
}
@@ -48,7 +48,7 @@ func TestBuildConfigAddOptsFlags(t *testing.T) {
func TestConfig_Add(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := New(repoProto, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -147,7 +147,7 @@ func TestBuildConfigGetRegexpOptsFlags(t *testing.T) {
func TestConfig_GetRegexp(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := New(repoProto, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -258,7 +258,7 @@ func TestConfig_UnsetAll(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := New(repoProto, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/git/localrepo/objects.go b/internal/git/localrepo/objects.go
index adfdb8ca8..9eb6fde05 100644
--- a/internal/git/localrepo/objects.go
+++ b/internal/git/localrepo/objects.go
@@ -205,7 +205,7 @@ func (repo *Repo) ReadCommit(ctx context.Context, revision git.Revision, opts ..
opt(&cfg)
}
- c, err := catfile.New(ctx, repo.commandFactory, repo)
+ c, err := catfile.New(ctx, repo.gitCmdFactory, repo)
if err != nil {
return nil, err
}
diff --git a/internal/git/localrepo/objects_test.go b/internal/git/localrepo/objects_test.go
index 5ee584c79..8c24c8210 100644
--- a/internal/git/localrepo/objects_test.go
+++ b/internal/git/localrepo/objects_test.go
@@ -31,7 +31,7 @@ func TestRepo_WriteBlob(t *testing.T) {
pbRepo, repoPath, clean := testhelper.InitBareRepo(t)
defer clean()
- repo := New(pbRepo, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), pbRepo, config.Config)
for _, tc := range []struct {
desc string
@@ -157,7 +157,7 @@ func TestRepo_WriteTag(t *testing.T) {
pbRepo, repoPath, clean := testhelper.NewTestRepo(t)
defer clean()
- repo := New(pbRepo, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), pbRepo, config.Config)
for _, tc := range []struct {
desc string
@@ -208,7 +208,7 @@ func TestRepo_ReadObject(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := New(testRepo, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
for _, tc := range []struct {
desc string
@@ -243,7 +243,7 @@ func TestRepo_ReadCommit(t *testing.T) {
repoProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := New(repoProto, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
for _, tc := range []struct {
desc string
diff --git a/internal/git/localrepo/refs_test.go b/internal/git/localrepo/refs_test.go
index dc55b717a..893abe8d6 100644
--- a/internal/git/localrepo/refs_test.go
+++ b/internal/git/localrepo/refs_test.go
@@ -22,7 +22,7 @@ func TestRepo_ContainsRef(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := New(testRepo, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
testcases := []struct {
desc string
@@ -62,7 +62,7 @@ func TestRepo_GetReference(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := New(testRepo, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
testcases := []struct {
desc string
@@ -111,7 +111,7 @@ func TestRepo_GetReferences(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := New(testRepo, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
testcases := []struct {
desc string
@@ -166,7 +166,7 @@ func TestRepo_GetBranches(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := New(testRepo, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
refs, err := repo.GetBranches(ctx)
require.NoError(t, err)
@@ -185,7 +185,9 @@ func TestRepo_UpdateRef(t *testing.T) {
}(config.Config.Ruby.Dir)
config.Config.Ruby.Dir = "/var/empty"
- otherRef, err := New(testRepo, config.Config).GetReference(ctx, "refs/heads/gitaly-test-ref")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+
+ otherRef, err := New(gitCmdFactory, testRepo, config.Config).GetReference(ctx, "refs/heads/gitaly-test-ref")
require.NoError(t, err)
testcases := []struct {
@@ -286,7 +288,7 @@ func TestRepo_UpdateRef(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := New(testRepo, config.Config)
+ repo := New(gitCmdFactory, testRepo, config.Config)
err := repo.UpdateRef(ctx, git.ReferenceName(tc.ref), tc.newValue, tc.oldValue)
tc.verify(t, repo, err)
diff --git a/internal/git/localrepo/remote_test.go b/internal/git/localrepo/remote_test.go
index 4bc9b42da..0e811e787 100644
--- a/internal/git/localrepo/remote_test.go
+++ b/internal/git/localrepo/remote_test.go
@@ -20,7 +20,7 @@ import (
func TestRepo_Remote(t *testing.T) {
repository := &gitalypb.Repository{StorageName: "stub", RelativePath: "/stub"}
- repo := New(repository, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), repository, config.Config)
require.Equal(t, Remote{repo: repo}, repo.Remote())
}
@@ -72,7 +72,7 @@ func TestRemote_Add(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := New(repoProto, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
_, remoteRepoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -150,7 +150,7 @@ func TestRemote_Add(t *testing.T) {
func TestRemote_Remove(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := New(repoProto, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -204,7 +204,7 @@ func TestBuildSetURLOptsFlags(t *testing.T) {
func TestRemote_SetURL(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := New(repoProto, config.Config)
+ repo := New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -265,6 +265,8 @@ func TestRepo_FetchRemote(t *testing.T) {
}(config.Config.Ruby.Dir)
config.Config.Ruby.Dir = "/var/empty"
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+
ctx, cancel := testhelper.Context()
defer cancel()
@@ -284,11 +286,11 @@ func TestRepo_FetchRemote(t *testing.T) {
t.FailNow()
}
- return New(testRepo, config.Config), testRepoPath, cleanup
+ return New(gitCmdFactory, testRepo, config.Config), testRepoPath, cleanup
}
t.Run("invalid name", func(t *testing.T) {
- repo := New(nil, config.Config)
+ repo := New(gitCmdFactory, nil, config.Config)
err := repo.FetchRemote(ctx, " ", FetchOpts{})
require.True(t, errors.Is(err, git.ErrInvalidArg))
@@ -299,7 +301,7 @@ func TestRepo_FetchRemote(t *testing.T) {
testRepo, _, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := New(testRepo, config.Config)
+ repo := New(gitCmdFactory, testRepo, config.Config)
var stderr bytes.Buffer
err := repo.FetchRemote(ctx, "stub", FetchOpts{Stderr: &stderr})
require.Error(t, err)
@@ -334,7 +336,7 @@ func TestRepo_FetchRemote(t *testing.T) {
testRepo, testRepoPath, testCleanup := testhelper.NewTestRepo(t)
defer testCleanup()
- repo := New(testRepo, config.Config)
+ repo := New(gitCmdFactory, testRepo, config.Config)
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "remote", "add", "source", sourceRepoPath)
var stderr bytes.Buffer
@@ -349,7 +351,7 @@ func TestRepo_FetchRemote(t *testing.T) {
testRepo, testRepoPath, testCleanup := testhelper.NewTestRepo(t)
defer testCleanup()
- repo := New(testRepo, config.Config)
+ repo := New(gitCmdFactory, testRepo, config.Config)
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "remote", "add", "source", sourceRepoPath)
require.NoError(t, repo.FetchRemote(ctx, "source", FetchOpts{}))
@@ -377,7 +379,7 @@ func TestRepo_FetchRemote(t *testing.T) {
testRepo, testRepoPath, testCleanup := testhelper.NewTestRepo(t)
defer testCleanup()
- repo := New(testRepo, config.Config)
+ repo := New(gitCmdFactory, testRepo, config.Config)
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "remote", "add", "source", sourceRepoPath)
require.NoError(t, repo.FetchRemote(ctx, "source", FetchOpts{}))
diff --git a/internal/git/localrepo/repo.go b/internal/git/localrepo/repo.go
index 07eac7590..5e0933f86 100644
--- a/internal/git/localrepo/repo.go
+++ b/internal/git/localrepo/repo.go
@@ -13,23 +13,23 @@ import (
// Repo represents a local Git repository.
type Repo struct {
repository.GitRepo
- commandFactory *git.ExecCommandFactory
- cfg config.Cfg
+ gitCmdFactory git.CommandFactory
+ cfg config.Cfg
}
// New creates a new Repo from its protobuf representation.
-func New(repo repository.GitRepo, cfg config.Cfg) *Repo {
+func New(gitCmdFactory git.CommandFactory, repo repository.GitRepo, cfg config.Cfg) *Repo {
return &Repo{
- GitRepo: repo,
- cfg: cfg,
- commandFactory: git.NewExecCommandFactory(cfg),
+ GitRepo: repo,
+ cfg: cfg,
+ gitCmdFactory: gitCmdFactory,
}
}
// Exec creates a git command with the given args and Repo, executed in the
// Repo. It validates the arguments in the command before executing.
func (repo *Repo) Exec(ctx context.Context, globals []git.GlobalOption, cmd git.Cmd, opts ...git.CmdOpt) (*command.Command, error) {
- return repo.commandFactory.New(ctx, repo, globals, cmd, opts...)
+ return repo.gitCmdFactory.New(ctx, repo, globals, cmd, opts...)
}
// ExecAndWait is similar to Exec, but waits for the command to exit before
diff --git a/internal/git/localrepo/repo_test.go b/internal/git/localrepo/repo_test.go
index 931213a58..04d5e331a 100644
--- a/internal/git/localrepo/repo_test.go
+++ b/internal/git/localrepo/repo_test.go
@@ -11,6 +11,6 @@ import (
func TestRepo(t *testing.T) {
git.TestRepository(t, func(t testing.TB, pbRepo *gitalypb.Repository) git.Repository {
t.Helper()
- return New(pbRepo, config.Config)
+ return New(git.NewExecCommandFactory(config.Config), pbRepo, config.Config)
})
}
diff --git a/internal/git/updateref/updateref_test.go b/internal/git/updateref/updateref_test.go
index cec69a005..395da5f3b 100644
--- a/internal/git/updateref/updateref_test.go
+++ b/internal/git/updateref/updateref_test.go
@@ -26,7 +26,7 @@ func testMain(m *testing.M) int {
return m.Run()
}
-func setup(t *testing.T) (context.Context, *localrepo.Repo, string, func()) {
+func setup(t *testing.T, cfg config.Cfg) (context.Context, *localrepo.Repo, string, func()) {
ctx, cancel := testhelper.Context()
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
teardown := func() {
@@ -34,13 +34,13 @@ func setup(t *testing.T) (context.Context, *localrepo.Repo, string, func()) {
cleanup()
}
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(cfg), repoProto, cfg)
return ctx, repo, repoPath, teardown
}
func TestCreate(t *testing.T) {
- ctx, repo, _, teardown := setup(t)
+ ctx, repo, _, teardown := setup(t, config.Config)
defer teardown()
headCommit, err := repo.ReadCommit(ctx, "HEAD")
@@ -62,7 +62,7 @@ func TestCreate(t *testing.T) {
}
func TestUpdate(t *testing.T) {
- ctx, repo, _, teardown := setup(t)
+ ctx, repo, _, teardown := setup(t, config.Config)
defer teardown()
headCommit, err := repo.ReadCommit(ctx, "HEAD")
@@ -99,7 +99,7 @@ func TestUpdate(t *testing.T) {
}
func TestDelete(t *testing.T) {
- ctx, repo, _, teardown := setup(t)
+ ctx, repo, _, teardown := setup(t, config.Config)
defer teardown()
updater, err := New(ctx, config.Config, git.NewExecCommandFactory(config.Config), repo)
@@ -116,7 +116,7 @@ func TestDelete(t *testing.T) {
}
func TestBulkOperation(t *testing.T) {
- ctx, repo, _, teardown := setup(t)
+ ctx, repo, _, teardown := setup(t, config.Config)
defer teardown()
headCommit, err := repo.ReadCommit(ctx, "HEAD")
@@ -138,7 +138,7 @@ func TestBulkOperation(t *testing.T) {
}
func TestContextCancelAbortsRefChanges(t *testing.T) {
- ctx, repo, _, teardown := setup(t)
+ ctx, repo, _, teardown := setup(t, config.Config)
defer teardown()
headCommit, err := repo.ReadCommit(ctx, "HEAD")
@@ -162,12 +162,8 @@ func TestContextCancelAbortsRefChanges(t *testing.T) {
}
func TestUpdater_closingStdinAbortsChanges(t *testing.T) {
- ctx, cancel := testhelper.Context()
- defer cancel()
-
- repoProto, _, cleanup := testhelper.NewTestRepo(t)
- defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ ctx, repo, _, teardown := setup(t, config.Config)
+ defer teardown()
headCommit, err := repo.ReadCommit(ctx, "HEAD")
require.NoError(t, err)
diff --git a/internal/git2go/apply_test.go b/internal/git2go/apply_test.go
index b782cf13e..f14a97daf 100644
--- a/internal/git2go/apply_test.go
+++ b/internal/git2go/apply_test.go
@@ -8,6 +8,7 @@ import (
"time"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -17,7 +18,7 @@ func TestExecutor_Apply(t *testing.T) {
pbRepo, repoPath, clean := testhelper.InitBareRepo(t)
defer clean()
- repo := localrepo.New(pbRepo, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), pbRepo, config.Config)
executor := New(filepath.Join(config.Config.BinDir, "gitaly-git2go"), config.Config.Git.BinPath)
ctx, cancel := testhelper.Context()
diff --git a/internal/git2go/commit_test.go b/internal/git2go/commit_test.go
index 1e4243c20..7a68081e7 100644
--- a/internal/git2go/commit_test.go
+++ b/internal/git2go/commit_test.go
@@ -13,6 +13,7 @@ import (
"time"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -55,7 +56,7 @@ func TestExecutor_Commit(t *testing.T) {
pbRepo, repoPath, clean := testhelper.InitBareRepo(t)
defer clean()
- repo := localrepo.New(pbRepo, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), pbRepo, config.Config)
originalFile, err := repo.WriteBlob(ctx, "file", bytes.NewBufferString("original"))
require.NoError(t, err)
diff --git a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
index 7528834ca..ee1582781 100644
--- a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
+++ b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go
@@ -26,7 +26,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(testRepo, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/gitaly/service/commit/find_commit.go b/internal/gitaly/service/commit/find_commit.go
index b37510aac..349725235 100644
--- a/internal/gitaly/service/commit/find_commit.go
+++ b/internal/gitaly/service/commit/find_commit.go
@@ -16,7 +16,7 @@ func (s *server) FindCommit(ctx context.Context, in *gitalypb.FindCommitRequest)
return nil, helper.ErrInvalidArgument(err)
}
- repo := localrepo.New(in.GetRepository(), s.cfg)
+ repo := localrepo.New(s.gitCmdFactory, in.GetRepository(), s.cfg)
var opts []localrepo.ReadCommitOpt
if in.GetTrailers() {
diff --git a/internal/gitaly/service/commit/find_commit_test.go b/internal/gitaly/service/commit/find_commit_test.go
index fa8f12c12..7e21ded20 100644
--- a/internal/gitaly/service/commit/find_commit_test.go
+++ b/internal/gitaly/service/commit/find_commit_test.go
@@ -32,7 +32,7 @@ func TestSuccessfulFindCommitRequest(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/gitaly/service/commit/list_files.go b/internal/gitaly/service/commit/list_files.go
index 20b1d8d9f..f653545aa 100644
--- a/internal/gitaly/service/commit/list_files.go
+++ b/internal/gitaly/service/commit/list_files.go
@@ -45,7 +45,7 @@ func (s *server) ListFiles(in *gitalypb.ListFilesRequest, stream gitalypb.Commit
revision = string(defaultBranch)
}
- contained, err := localrepo.New(in.Repository, s.cfg).HasRevision(stream.Context(), git.Revision(revision))
+ contained, err := localrepo.New(s.gitCmdFactory, in.Repository, s.cfg).HasRevision(stream.Context(), git.Revision(revision))
if err != nil {
return helper.ErrInternal(err)
}
diff --git a/internal/gitaly/service/commit/stats.go b/internal/gitaly/service/commit/stats.go
index da38d039d..d466b6b84 100644
--- a/internal/gitaly/service/commit/stats.go
+++ b/internal/gitaly/service/commit/stats.go
@@ -27,7 +27,7 @@ func (s *server) CommitStats(ctx context.Context, in *gitalypb.CommitStatsReques
}
func (s *server) commitStats(ctx context.Context, in *gitalypb.CommitStatsRequest) (*gitalypb.CommitStatsResponse, error) {
- repo := localrepo.New(in.Repository, s.cfg)
+ repo := localrepo.New(s.gitCmdFactory, in.Repository, s.cfg)
commit, err := repo.ReadCommit(ctx, git.Revision(in.Revision))
if err != nil {
diff --git a/internal/gitaly/service/conflicts/list_conflict_files.go b/internal/gitaly/service/conflicts/list_conflict_files.go
index dac9e1525..51189d554 100644
--- a/internal/gitaly/service/conflicts/list_conflict_files.go
+++ b/internal/gitaly/service/conflicts/list_conflict_files.go
@@ -22,7 +22,7 @@ func (s *server) ListConflictFiles(request *gitalypb.ListConflictFilesRequest, s
return helper.ErrInvalidArgument(err)
}
- repo := localrepo.New(request.Repository, s.cfg)
+ repo := localrepo.New(s.gitCmdFactory, request.Repository, s.cfg)
ours, err := repo.ResolveRevision(ctx, git.Revision(request.OurCommitOid+"^{commit}"))
if err != nil {
diff --git a/internal/gitaly/service/conflicts/list_conflict_files_test.go b/internal/gitaly/service/conflicts/list_conflict_files_test.go
index 396aeb3d3..92c05cd52 100644
--- a/internal/gitaly/service/conflicts/list_conflict_files_test.go
+++ b/internal/gitaly/service/conflicts/list_conflict_files_test.go
@@ -210,7 +210,7 @@ func buildCommit(t *testing.T, ctx context.Context, repo *gitalypb.Repository, r
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "commit", "-m", "message")
- oid, err := localrepo.New(repo, config.Config).ResolveRevision(ctx, git.Revision("HEAD"))
+ oid, err := localrepo.New(git.NewExecCommandFactory(config.Config), repo, config.Config).ResolveRevision(ctx, git.Revision("HEAD"))
require.NoError(t, err)
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "reset", "--hard", "HEAD~")
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts.go b/internal/gitaly/service/conflicts/resolve_conflicts.go
index 800b402a4..12af79c9b 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts.go
@@ -226,7 +226,7 @@ func (s *server) resolveConflicts(header *gitalypb.ResolveConflictsRequestHeader
return err
}
- if err := localrepo.New(header.GetRepository(), s.cfg).UpdateRef(
+ if err := localrepo.New(s.gitCmdFactory, header.GetRepository(), s.cfg).UpdateRef(
stream.Context(),
git.ReferenceName("refs/heads/"+string(header.GetSourceBranch())),
commitOID,
@@ -270,7 +270,7 @@ func sameRepo(left, right *gitalypb.Repository) bool {
func (s *server) repoWithBranchCommit(ctx context.Context, srcRepo, targetRepo *gitalypb.Repository, srcBranch, targetBranch []byte) error {
const peelCommit = "^{commit}"
- src := localrepo.New(srcRepo, s.cfg)
+ src := localrepo.New(s.gitCmdFactory, srcRepo, s.cfg)
if sameRepo(srcRepo, targetRepo) {
_, err := src.ResolveRevision(ctx, git.Revision(string(targetBranch)+peelCommit))
return err
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
index 3ed61e28d..45471a994 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
@@ -67,7 +67,7 @@ func testSuccessfulResolveConflictsRequest(t *testing.T, ctx context.Context) {
testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(testRepo, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
ctxOuter, cancel := testhelper.Context()
defer cancel()
@@ -115,7 +115,7 @@ func testSuccessfulResolveConflictsRequest(t *testing.T, ctx context.Context) {
// introduce a conflict that exists on both branches, but not the
// ancestor
commitConflict := func(parentCommitID, branch, blob string) string {
- blobID, err := localrepo.New(testRepo, config.Config).WriteBlob(ctx, "", strings.NewReader(blob))
+ blobID, err := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config).WriteBlob(ctx, "", strings.NewReader(blob))
require.NoError(t, err)
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "read-tree", branch)
testhelper.MustRunCommand(t, nil,
@@ -207,7 +207,7 @@ func testResolveConflictsStableID(t *testing.T, ctx context.Context) {
repoProto, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
md := testhelper.GitalyServersMetadata(t, serverSocketPath)
ctx = testhelper.MergeOutgoingMetadata(ctx, md)
diff --git a/internal/gitaly/service/diff/find_changed_paths.go b/internal/gitaly/service/diff/find_changed_paths.go
index 172e11006..68a85fd03 100644
--- a/internal/gitaly/service/diff/find_changed_paths.go
+++ b/internal/gitaly/service/diff/find_changed_paths.go
@@ -135,7 +135,7 @@ func (s *server) validateFindChangedPathsRequestParams(ctx context.Context, in *
return err
}
- gitRepo := localrepo.New(repo, s.cfg)
+ gitRepo := localrepo.New(s.gitCmdFactory, repo, s.cfg)
for _, commit := range in.GetCommits() {
if commit == "" {
diff --git a/internal/gitaly/service/objectpool/link_test.go b/internal/gitaly/service/objectpool/link_test.go
index 86371abc4..8ddf32a40 100644
--- a/internal/gitaly/service/objectpool/link_test.go
+++ b/internal/gitaly/service/objectpool/link_test.go
@@ -30,7 +30,7 @@ func TestLink(t *testing.T) {
repoProto, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
pool, err := objectpool.NewObjectPool(config.Config, locator, git.NewExecCommandFactory(config.Config), repoProto.GetStorageName(), testhelper.NewTestObjectPoolName(t))
require.NoError(t, err)
diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go
index 05c2d7335..7e6b47dda 100644
--- a/internal/gitaly/service/operations/apply_patch_test.go
+++ b/internal/gitaly/service/operations/apply_patch_test.go
@@ -37,7 +37,7 @@ func testSuccessfulUserApplyPatch(t *testing.T, ctx context.Context) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
testPatchReadme := "testdata/0001-A-commit-from-a-patch.patch"
testPatchFeature := "testdata/0001-This-does-not-apply-to-the-feature-branch.patch"
@@ -149,7 +149,7 @@ func TestUserApplyPatch_stableID(t *testing.T) {
repoProto, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/gitaly/service/operations/branches.go b/internal/gitaly/service/operations/branches.go
index 430e76ce6..c21d4ecf8 100644
--- a/internal/gitaly/service/operations/branches.go
+++ b/internal/gitaly/service/operations/branches.go
@@ -28,7 +28,7 @@ func (s *Server) UserCreateBranch(ctx context.Context, req *gitalypb.UserCreateB
return nil, status.Errorf(codes.InvalidArgument, "empty start point")
}
- repo := localrepo.New(req.Repository, s.cfg)
+ repo := localrepo.New(s.gitCmdFactory, req.Repository, s.cfg)
// BEGIN TODO: Uncomment if StartPoint started behaving sensibly
// like BranchName. See
@@ -162,7 +162,7 @@ func (s *Server) UserDeleteBranch(ctx context.Context, req *gitalypb.UserDeleteB
referenceFmt = "%s"
}
referenceName := fmt.Sprintf(referenceFmt, req.BranchName)
- referenceValue, err := localrepo.New(req.Repository, s.cfg).GetReference(ctx, git.ReferenceName(referenceName))
+ referenceValue, err := localrepo.New(s.gitCmdFactory, req.Repository, s.cfg).GetReference(ctx, git.ReferenceName(referenceName))
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition, "branch not found: %s", req.BranchName)
}
diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go
index 6efafc25c..5e1d75d4d 100644
--- a/internal/gitaly/service/operations/branches_test.go
+++ b/internal/gitaly/service/operations/branches_test.go
@@ -41,7 +41,7 @@ func TestSuccessfulCreateBranchRequest(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
serverSocketPath, stop := runOperationServiceServer(t)
defer stop()
@@ -269,7 +269,7 @@ func TestSuccessfulCreateBranchRequestWithStartPointRefPrefix(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
testCases := []struct {
desc string
diff --git a/internal/gitaly/service/operations/cherry_pick_test.go b/internal/gitaly/service/operations/cherry_pick_test.go
index a5acabaab..1d714c489 100644
--- a/internal/gitaly/service/operations/cherry_pick_test.go
+++ b/internal/gitaly/service/operations/cherry_pick_test.go
@@ -27,7 +27,7 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
destinationBranch := "cherry-picking-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", destinationBranch, "master")
@@ -158,7 +158,7 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) {
response, err := client.UserCherryPick(ctx, testCase.request)
require.NoError(t, err)
- testRepo := localrepo.New(testCase.request.Repository, config.Config)
+ testRepo := localrepo.New(git.NewExecCommandFactory(config.Config), testCase.request.Repository, config.Config)
headCommit, err := testRepo.ReadCommit(ctx, git.Revision(testCase.request.BranchName))
require.NoError(t, err)
@@ -196,7 +196,7 @@ func testSuccessfulGitHooksForUserCherryPickRequest(t *testing.T, ctxOuter conte
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
destinationBranch := "cherry-picking-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", destinationBranch, "master")
@@ -241,7 +241,7 @@ func TestUserCherryPick_stableID(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -309,7 +309,7 @@ func TestFailedUserCherryPickRequestDueToValidations(t *testing.T) {
repoProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
cherryPickedCommit, err := repo.ReadCommit(ctxOuter, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
require.NoError(t, err)
@@ -390,7 +390,7 @@ func TestFailedUserCherryPickRequestDueToPreReceiveError(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
destinationBranch := "cherry-picking-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", destinationBranch, "master")
@@ -435,7 +435,7 @@ func TestFailedUserCherryPickRequestDueToCreateTreeError(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
destinationBranch := "cherry-picking-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", destinationBranch, "master")
@@ -473,7 +473,7 @@ func TestFailedUserCherryPickRequestDueToCommitError(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
sourceBranch := "cherry-pick-src"
destinationBranch := "cherry-picking-dst"
diff --git a/internal/gitaly/service/operations/commit_files.go b/internal/gitaly/service/operations/commit_files.go
index 8161bef8e..889ea2d10 100644
--- a/internal/gitaly/service/operations/commit_files.go
+++ b/internal/gitaly/service/operations/commit_files.go
@@ -184,7 +184,7 @@ func (s *Server) userCommitFiles(ctx context.Context, header *gitalypb.UserCommi
remoteRepo = nil
}
- localRepo := localrepo.New(header.Repository, s.cfg)
+ localRepo := localrepo.New(s.gitCmdFactory, header.Repository, s.cfg)
targetBranchName := "refs/heads/" + string(header.BranchName)
targetBranchCommit, err := localRepo.ResolveRevision(ctx, git.Revision(targetBranchName+"^{commit}"))
@@ -431,7 +431,7 @@ func (s *Server) resolveParentCommit(ctx context.Context, local git.Repository,
}
func (s *Server) fetchMissingCommit(ctx context.Context, local, remote *gitalypb.Repository, commitID string) error {
- if _, err := localrepo.New(local, s.cfg).ResolveRevision(ctx, git.Revision(commitID+"^{commit}")); err != nil {
+ if _, err := localrepo.New(s.gitCmdFactory, local, s.cfg).ResolveRevision(ctx, git.Revision(commitID+"^{commit}")); err != nil {
if !errors.Is(err, git.ErrReferenceNotFound) || remote == nil {
return fmt.Errorf("lookup parent commit: %w", err)
}
diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go
index 64d0f2927..507c817c8 100644
--- a/internal/gitaly/service/operations/commit_files_test.go
+++ b/internal/gitaly/service/operations/commit_files_test.go
@@ -966,7 +966,7 @@ func testUserCommitFilesStableCommitID(t *testing.T, ctx context.Context) {
repoProto, repoPath, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
for key, values := range testhelper.GitalyServersMetadata(t, serverSocketPath) {
for _, value := range values {
@@ -1104,7 +1104,7 @@ func testSuccessfulUserCommitFilesRequest(t *testing.T, ctx context.Context) {
require.Equal(t, tc.repoCreated, resp.GetBranchUpdate().GetRepoCreated())
require.Equal(t, tc.branchCreated, resp.GetBranchUpdate().GetBranchCreated())
- headCommit, err := localrepo.New(tc.repo, config.Config).ReadCommit(ctx, git.Revision(tc.branchName))
+ headCommit, err := localrepo.New(git.NewExecCommandFactory(config.Config), tc.repo, config.Config).ReadCommit(ctx, git.Revision(tc.branchName))
require.NoError(t, err)
require.Equal(t, authorName, headCommit.Author.Name)
require.Equal(t, testhelper.TestUser.Name, headCommit.Committer.Name)
@@ -1200,7 +1200,7 @@ func testSuccessfulUserCommitFilesRequestForceCommit(t *testing.T, ctx context.C
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
authorName := []byte("Jane Doe")
authorEmail := []byte("janedoe@gitlab.com")
@@ -1252,7 +1252,7 @@ func testSuccessfulUserCommitFilesRequestStartSha(t *testing.T, ctx context.Cont
repoProto, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
targetBranchName := "new"
@@ -1301,13 +1301,15 @@ func testSuccessfulUserCommitFilesRemoteRepositoryRequest(setHeader func(header
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+
repoProto, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(gitCmdFactory, repoProto, config.Config)
newRepoProto, _, newRepoCleanupFn := testhelper.InitBareRepo(t)
defer newRepoCleanupFn()
- newRepo := localrepo.New(newRepoProto, config.Config)
+ newRepo := localrepo.New(gitCmdFactory, newRepoProto, config.Config)
for key, values := range testhelper.GitalyServersMetadata(t, serverSocketPath) {
for _, value := range values {
@@ -1355,7 +1357,7 @@ func testSuccessfulUserCommitFilesRequestWithSpecialCharactersInSignature(t *tes
repoProto, _, cleanupFn := testhelper.InitBareRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
targetBranchName := "master"
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go
index f9833e7a3..48b2dc727 100644
--- a/internal/gitaly/service/operations/merge.go
+++ b/internal/gitaly/service/operations/merge.go
@@ -59,7 +59,7 @@ func (s *Server) UserMergeBranch(stream gitalypb.OperationService_UserMergeBranc
}
branch := "refs/heads/" + text.ChompBytes(firstRequest.Branch)
- revision, err := localrepo.New(repo, s.cfg).ResolveRevision(ctx, git.Revision(branch))
+ revision, err := localrepo.New(s.gitCmdFactory, repo, s.cfg).ResolveRevision(ctx, git.Revision(branch))
if err != nil {
return err
}
@@ -159,7 +159,7 @@ func (s *Server) UserFFBranch(ctx context.Context, in *gitalypb.UserFFBranchRequ
}
branch := fmt.Sprintf("refs/heads/%s", in.Branch)
- revision, err := localrepo.New(in.Repository, s.cfg).ResolveRevision(ctx, git.Revision(branch))
+ revision, err := localrepo.New(s.gitCmdFactory, in.Repository, s.cfg).ResolveRevision(ctx, git.Revision(branch))
if err != nil {
return nil, helper.ErrInvalidArgument(err)
}
@@ -249,7 +249,7 @@ func (s *Server) UserMergeToRef(ctx context.Context, request *gitalypb.UserMerge
return nil, err
}
- repo := localrepo.New(request.Repository, s.cfg)
+ repo := localrepo.New(s.gitCmdFactory, request.Repository, s.cfg)
revision := git.Revision(request.Branch)
if request.FirstParentRef != nil {
diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go
index 515d13a32..2b0d9c1a1 100644
--- a/internal/gitaly/service/operations/merge_test.go
+++ b/internal/gitaly/service/operations/merge_test.go
@@ -41,7 +41,7 @@ func testWithFeature(t *testing.T, feature featureflag.FeatureFlag, testcase fun
func TestSuccessfulMerge(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
serverSocketPath, stop := runOperationServiceServer(t)
defer stop()
@@ -130,7 +130,7 @@ func TestSuccessfulMerge(t *testing.T) {
func TestSuccessfulMerge_stableMergeIDs(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
serverSocketPath, stop := runOperationServiceServer(t)
defer stop()
@@ -211,7 +211,7 @@ func TestAbortedMerge(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", mergeBranchName, mergeBranchHeadBefore)
@@ -274,7 +274,7 @@ func TestAbortedMerge(t *testing.T) {
func TestFailedMergeConcurrentUpdate(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
serverSocketPath, stop := runOperationServiceServer(t)
defer stop()
@@ -322,7 +322,7 @@ func TestFailedMergeConcurrentUpdate(t *testing.T) {
func TestUserMergeBranch_ambiguousReference(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
serverSocketPath, stop := runOperationServiceServer(t)
defer stop()
@@ -691,7 +691,7 @@ func TestSuccessfulUserMergeToRefRequest(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", mergeBranchName, mergeBranchHeadBefore)
@@ -851,7 +851,7 @@ func TestUserMergeToRef_stableMergeID(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", mergeBranchName, mergeBranchHeadBefore)
diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go
index f8db29d55..212fd6cfb 100644
--- a/internal/gitaly/service/operations/rebase_test.go
+++ b/internal/gitaly/service/operations/rebase_test.go
@@ -45,7 +45,7 @@ func TestSuccessfulUserRebaseConfirmableRequest(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
repoCopyProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -121,7 +121,7 @@ func TestUserRebaseConfirmable_stableCommitIDs(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -342,7 +342,7 @@ func TestFailedUserRebaseConfirmableDueToApplyBeingFalse(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
testRepoCopy, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -389,7 +389,7 @@ func TestFailedUserRebaseConfirmableRequestDueToPreReceiveError(t *testing.T) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
repoCopyProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -496,7 +496,7 @@ func TestRebaseRequestWithDeletedFile(t *testing.T) {
repoProto, repoProtoPath, cleanupFn := testhelper.NewTestRepoWithWorktree(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
repoCopyProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
@@ -554,7 +554,7 @@ func TestRebaseOntoRemoteBranch(t *testing.T) {
localRepoProto, localRepoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- localRepo := localrepo.New(localRepoProto, config.Config)
+ localRepo := localrepo.New(git.NewExecCommandFactory(config.Config), localRepoProto, config.Config)
remoteRepo, remoteRepoPath, cleanup := testhelper.NewTestRepoWithWorktree(t)
defer cleanup()
diff --git a/internal/gitaly/service/operations/revert.go b/internal/gitaly/service/operations/revert.go
index 2a47c5086..8f8780a7d 100644
--- a/internal/gitaly/service/operations/revert.go
+++ b/internal/gitaly/service/operations/revert.go
@@ -30,7 +30,7 @@ func (s *Server) UserRevert(ctx context.Context, req *gitalypb.UserRevertRequest
return nil, err
}
- localRepo := localrepo.New(req.Repository, s.cfg)
+ localRepo := localrepo.New(s.gitCmdFactory, req.Repository, s.cfg)
repoHadBranches, err := localRepo.HasBranches(ctx)
if err != nil {
return nil, err
@@ -162,7 +162,7 @@ func (s *Server) fetchStartRevision(ctx context.Context, req *gitalypb.UserRever
return startRevision.String(), nil
}
- _, err = localrepo.New(req.Repository, s.cfg).ResolveRevision(ctx, startRevision.Revision()+"^{commit}")
+ _, err = localrepo.New(s.gitCmdFactory, req.Repository, s.cfg).ResolveRevision(ctx, startRevision.Revision()+"^{commit}")
if errors.Is(err, git.ErrReferenceNotFound) {
if err := s.fetchRemoteObject(ctx, req.Repository, req.StartRepository, startRevision.String()); err != nil {
return "", helper.ErrInternalf("fetch start: %w", err)
diff --git a/internal/gitaly/service/operations/revert_test.go b/internal/gitaly/service/operations/revert_test.go
index 2b71be6d9..524a151df 100644
--- a/internal/gitaly/service/operations/revert_test.go
+++ b/internal/gitaly/service/operations/revert_test.go
@@ -28,7 +28,7 @@ func testServerUserRevertSuccessful(t *testing.T, ctxOuter context.Context) {
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
destinationBranch := "revert-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", destinationBranch, "master")
@@ -159,7 +159,7 @@ func testServerUserRevertSuccessful(t *testing.T, ctxOuter context.Context) {
response, err := client.UserRevert(ctx, testCase.request)
require.NoError(t, err)
- testCaseRepo := localrepo.New(testCase.request.Repository, config.Config)
+ testCaseRepo := localrepo.New(git.NewExecCommandFactory(config.Config), testCase.request.Repository, config.Config)
headCommit, err := testCaseRepo.ReadCommit(ctx, git.Revision(testCase.request.BranchName))
require.NoError(t, err)
@@ -194,7 +194,7 @@ func testServerUserRevertStableID(t *testing.T, ctxOuter context.Context) {
repoProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
md := testhelper.GitalyServersMetadata(t, serverSocketPath)
ctx := testhelper.MergeOutgoingMetadata(ctxOuter, md)
@@ -256,9 +256,11 @@ func testServerUserRevertSuccessfulIntoNewRepo(t *testing.T, ctxOuter context.Co
client, conn := newOperationClient(t, serverSocketPath)
defer conn.Close()
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+
startRepoProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- startRepo := localrepo.New(startRepoProto, config.Config)
+ startRepo := localrepo.New(gitCmdFactory, startRepoProto, config.Config)
revertedCommit, err := startRepo.ReadCommit(ctxOuter, "d59c60028b053793cecfb4022de34602e1a9218e")
require.NoError(t, err)
@@ -268,7 +270,7 @@ func testServerUserRevertSuccessfulIntoNewRepo(t *testing.T, ctxOuter context.Co
repoProto, _, cleanup := testhelper.InitBareRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(gitCmdFactory, repoProto, config.Config)
request := &gitalypb.UserRevertRequest{
Repository: repoProto,
@@ -315,7 +317,7 @@ func testServerUserRevertSuccessfulGitHooks(t *testing.T, ctxOuter context.Conte
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
destinationBranch := "revert-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", destinationBranch, "master")
@@ -364,7 +366,7 @@ func testServerUserRevertFailuedDueToValidations(t *testing.T, ctxOuter context.
repoProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
revertedCommit, err := repo.ReadCommit(ctxOuter, "d59c60028b053793cecfb4022de34602e1a9218e")
require.NoError(t, err)
@@ -446,7 +448,7 @@ func testServerUserRevertFailedDueToPreReceiveError(t *testing.T, ctxOuter conte
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
destinationBranch := "revert-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", destinationBranch, "master")
@@ -492,7 +494,7 @@ func testServerUserRevertFailedDueToCreateTreeError(t *testing.T, ctxOuter conte
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
destinationBranch := "revert-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", destinationBranch, "master")
@@ -531,7 +533,7 @@ func testServerUserRevertFailedDueToCommitError(t *testing.T, ctxOuter context.C
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
sourceBranch := "revert-src"
destinationBranch := "revert-dst"
diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go
index c5a714472..75ef95981 100644
--- a/internal/gitaly/service/operations/squash_test.go
+++ b/internal/gitaly/service/operations/squash_test.go
@@ -55,7 +55,7 @@ func testSuccessfulUserSquashRequest(t *testing.T, ctx context.Context, start, e
repoProto, repoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
request := &gitalypb.UserSquashRequest{
Repository: repoProto,
@@ -94,7 +94,7 @@ func TestUserSquash_stableID(t *testing.T) {
repoProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
@@ -163,7 +163,7 @@ func TestSuccessfulUserSquashRequestWith3wayMerge(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
request := &gitalypb.UserSquashRequest{
Repository: repoProto,
@@ -247,7 +247,7 @@ func TestSquashRequestWithRenamedFiles(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepoWithWorktree(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
originalFilename := "original-file.txt"
renamedFilename := "renamed-file.txt"
diff --git a/internal/gitaly/service/operations/submodules.go b/internal/gitaly/service/operations/submodules.go
index 581045085..b906e1fb4 100644
--- a/internal/gitaly/service/operations/submodules.go
+++ b/internal/gitaly/service/operations/submodules.go
@@ -78,7 +78,7 @@ func validateUserUpdateSubmoduleRequest(req *gitalypb.UserUpdateSubmoduleRequest
}
func (s *Server) userUpdateSubmodule(ctx context.Context, req *gitalypb.UserUpdateSubmoduleRequest) (*gitalypb.UserUpdateSubmoduleResponse, error) {
- repo := localrepo.New(req.GetRepository(), s.cfg)
+ repo := localrepo.New(s.gitCmdFactory, req.GetRepository(), s.cfg)
branches, err := repo.GetBranches(ctx)
if err != nil {
return nil, fmt.Errorf("%s: get branches: %w", userUpdateSubmoduleName, err)
diff --git a/internal/gitaly/service/operations/submodules_test.go b/internal/gitaly/service/operations/submodules_test.go
index 364d658f6..c90bf0f8b 100644
--- a/internal/gitaly/service/operations/submodules_test.go
+++ b/internal/gitaly/service/operations/submodules_test.go
@@ -34,7 +34,7 @@ func testSuccessfulUserUpdateSubmoduleRequest(t *testing.T, ctx context.Context)
testRepoProto, testRepoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- testRepo := localrepo.New(testRepoProto, config.Config)
+ testRepo := localrepo.New(git.NewExecCommandFactory(config.Config), testRepoProto, config.Config)
// This reference is created to check that we can correctly commit onto
// a branch which has a name starting with "refs/heads/".
@@ -124,7 +124,7 @@ func testUserUpdateSubmoduleStableID(t *testing.T, ctx context.Context) {
repoProto, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
response, err := client.UserUpdateSubmodule(ctx, &gitalypb.UserUpdateSubmoduleRequest{
Repository: repoProto,
diff --git a/internal/gitaly/service/operations/tags.go b/internal/gitaly/service/operations/tags.go
index af672f84a..c3dd6cbc7 100644
--- a/internal/gitaly/service/operations/tags.go
+++ b/internal/gitaly/service/operations/tags.go
@@ -29,7 +29,7 @@ func (s *Server) UserDeleteTag(ctx context.Context, req *gitalypb.UserDeleteTagR
}
referenceName := fmt.Sprintf("refs/tags/%s", req.TagName)
- revision, err := localrepo.New(req.Repository, s.cfg).GetReference(ctx, git.ReferenceName(referenceName))
+ revision, err := localrepo.New(s.gitCmdFactory, req.Repository, s.cfg).GetReference(ctx, git.ReferenceName(referenceName))
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition, "tag not found: %s", req.TagName)
}
@@ -144,7 +144,7 @@ func (s *Server) UserCreateTag(ctx context.Context, req *gitalypb.UserCreateTagR
refObjectID := targetObjectID
var tagObject *gitalypb.Tag
if makingTag {
- localRepo := localrepo.New(repo, s.cfg)
+ localRepo := localrepo.New(s.gitCmdFactory, repo, s.cfg)
committerTime := time.Now()
if req.Timestamp != nil {
diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go
index 84286ec5d..c9a28aecd 100644
--- a/internal/gitaly/service/operations/tags_test.go
+++ b/internal/gitaly/service/operations/tags_test.go
@@ -185,7 +185,7 @@ func testSuccessfulUserCreateTagRequest(t *testing.T, ctx context.Context) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
targetRevision := "c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"
targetRevisionCommit, err := repo.ReadCommit(ctx, git.Revision(targetRevision))
@@ -281,7 +281,7 @@ func TestUserCreateTagWithTransaction(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
hooksOutputDir, cleanup := testhelper.TempDir(t)
defer cleanup()
@@ -751,7 +751,7 @@ func TestSuccessfulUserCreateTagNestedTags(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
preReceiveHook, cleanup := writeAssertObjectTypePreReceiveHook(t)
defer cleanup()
@@ -968,7 +968,7 @@ func TestUserCreateTagsuccessfulCreationOfPrefixedTag(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
serverSocketPath, stop := runOperationServiceServer(t)
defer stop()
diff --git a/internal/gitaly/service/operations/update_branches_test.go b/internal/gitaly/service/operations/update_branches_test.go
index 6ffd3cf36..bcde99d2e 100644
--- a/internal/gitaly/service/operations/update_branches_test.go
+++ b/internal/gitaly/service/operations/update_branches_test.go
@@ -33,7 +33,7 @@ func TestSuccessfulUserUpdateBranchRequest(t *testing.T) {
func testSuccessfulUserUpdateBranchRequest(t *testing.T, ctx context.Context) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
serverSocketPath, stop := runOperationServiceServer(t)
defer stop()
@@ -121,7 +121,7 @@ func testSuccessfulUserUpdateBranchRequestToDelete(t *testing.T, ctx context.Con
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
testCases := []struct {
desc string
@@ -277,7 +277,7 @@ func testFailedUserUpdateBranchRequest(t *testing.T, ctx context.Context) {
repoProto, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
revDoesntExist := fmt.Sprintf("%x", sha1.Sum([]byte("we need a non existent sha")))
diff --git a/internal/gitaly/service/operations/update_with_hooks_test.go b/internal/gitaly/service/operations/update_with_hooks_test.go
index 1a72f4c81..4e5ba034f 100644
--- a/internal/gitaly/service/operations/update_with_hooks_test.go
+++ b/internal/gitaly/service/operations/update_with_hooks_test.go
@@ -276,12 +276,12 @@ func TestUpdateReferenceWithHooks(t *testing.T) {
}
if tc.expectedRefDeletion {
- contained, err := localrepo.New(repo, config.Config).HasRevision(ctx, git.Revision("refs/heads/master"))
+ contained, err := localrepo.New(gitCmdFactory, repo, config.Config).HasRevision(ctx, git.Revision("refs/heads/master"))
require.NoError(t, err)
require.False(t, contained, "branch should have been deleted")
testhelper.MustRunCommand(t, nil, "git", "-C", repoPath, "branch", "master", oldRev)
} else {
- ref, err := localrepo.New(repo, config.Config).GetReference(ctx, "refs/heads/master")
+ ref, err := localrepo.New(gitCmdFactory, repo, config.Config).GetReference(ctx, "refs/heads/master")
require.NoError(t, err)
require.Equal(t, ref.Target, oldRev)
}
diff --git a/internal/gitaly/service/ref/branches.go b/internal/gitaly/service/ref/branches.go
index ba80b5105..5250786f9 100644
--- a/internal/gitaly/service/ref/branches.go
+++ b/internal/gitaly/service/ref/branches.go
@@ -16,7 +16,7 @@ func (s *server) FindBranch(ctx context.Context, req *gitalypb.FindBranchRequest
return nil, status.Errorf(codes.InvalidArgument, "Branch name cannot be empty")
}
- repo := localrepo.New(req.GetRepository(), s.cfg)
+ repo := localrepo.New(s.gitCmdFactory, req.GetRepository(), s.cfg)
branchName := git.NewReferenceNameFromBranchName(string(req.GetName()))
branchRef, err := repo.GetReference(ctx, branchName)
diff --git a/internal/gitaly/service/ref/branches_test.go b/internal/gitaly/service/ref/branches_test.go
index 837ec78cd..f70d22e54 100644
--- a/internal/gitaly/service/ref/branches_test.go
+++ b/internal/gitaly/service/ref/branches_test.go
@@ -25,7 +25,7 @@ func TestSuccessfulFindBranchRequest(t *testing.T) {
testRepoProto, _, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(testRepoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), testRepoProto, config.Config)
branchesByName := make(map[git.ReferenceName]*gitalypb.Branch)
for branchName, revision := range map[git.ReferenceName]git.Revision{
diff --git a/internal/gitaly/service/ref/delete_refs.go b/internal/gitaly/service/ref/delete_refs.go
index 922b1ab60..3c776292c 100644
--- a/internal/gitaly/service/ref/delete_refs.go
+++ b/internal/gitaly/service/ref/delete_refs.go
@@ -60,7 +60,7 @@ func (s *server) refsToRemove(ctx context.Context, req *gitalypb.DeleteRefsReque
prefixes[i] = string(prefix)
}
- existingRefs, err := localrepo.New(req.GetRepository(), s.cfg).GetReferences(ctx, "")
+ existingRefs, err := localrepo.New(s.gitCmdFactory, req.GetRepository(), s.cfg).GetReferences(ctx, "")
if err != nil {
return nil, err
}
diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go
index 49436fc9d..33bbc87d7 100644
--- a/internal/gitaly/service/ref/delete_refs_test.go
+++ b/internal/gitaly/service/ref/delete_refs_test.go
@@ -5,6 +5,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -55,7 +56,7 @@ func TestSuccessfulDeleteRefs(t *testing.T) {
require.NoError(t, err)
// Ensure that the internal refs are gone, but the others still exist
- refs, err := localrepo.New(repo, config.Config).GetReferences(ctx, "refs/")
+ refs, err := localrepo.New(git.NewExecCommandFactory(config.Config), repo, config.Config).GetReferences(ctx, "refs/")
require.NoError(t, err)
refNames := make([]string, len(refs))
diff --git a/internal/gitaly/service/ref/pack_refs_test.go b/internal/gitaly/service/ref/pack_refs_test.go
index 1d7706d0e..3aea0659b 100644
--- a/internal/gitaly/service/ref/pack_refs_test.go
+++ b/internal/gitaly/service/ref/pack_refs_test.go
@@ -33,7 +33,7 @@ func TestPackRefsSuccessfulRequest(t *testing.T) {
packedRefs := linesInPackfile(t, testRepoPath)
- repo := localrepo.New(testRepo, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config)
// creates some new heads
newBranches := 10
diff --git a/internal/gitaly/service/ref/refs_test.go b/internal/gitaly/service/ref/refs_test.go
index b8ab9f815..8a3cae551 100644
--- a/internal/gitaly/service/ref/refs_test.go
+++ b/internal/gitaly/service/ref/refs_test.go
@@ -483,7 +483,7 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepoWithWorktree(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
// reconstruct the v1.1.2 tag from patches to test truncated tag message
// with partial PGP block
@@ -1121,7 +1121,7 @@ func TestSuccessfulFindAllBranchesRequestWithMergedBranches(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
client, conn := newRefServiceClient(t, serverSocketPath)
defer conn.Close()
@@ -1444,7 +1444,7 @@ func TestSuccessfulFindTagRequest(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepoWithWorktree(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
blobID := "faaf198af3a36dbf41961466703cc1d47c61d051"
commitID := "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9"
diff --git a/internal/gitaly/service/ref/remote_branches_test.go b/internal/gitaly/service/ref/remote_branches_test.go
index bace51186..a41c7924f 100644
--- a/internal/gitaly/service/ref/remote_branches_test.go
+++ b/internal/gitaly/service/ref/remote_branches_test.go
@@ -25,7 +25,7 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) {
repoProto, repoPath, cleanupFn := testhelper.NewTestRepo(t)
defer cleanupFn()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
remoteName := "my-remote"
expectedBranches := map[string]string{
diff --git a/internal/gitaly/service/repository/create_from_bundle_test.go b/internal/gitaly/service/repository/create_from_bundle_test.go
index 05228923d..b9b130ebb 100644
--- a/internal/gitaly/service/repository/create_from_bundle_test.go
+++ b/internal/gitaly/service/repository/create_from_bundle_test.go
@@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/tempdir"
@@ -48,7 +49,7 @@ func TestServer_CreateRepositoryFromBundle_successful(t *testing.T) {
StorageName: testhelper.DefaultStorageName,
RelativePath: "a-repo-from-bundle",
}
- importedRepo := localrepo.New(importedRepoProto, config.Config)
+ importedRepo := localrepo.New(git.NewExecCommandFactory(config.Config), importedRepoProto, config.Config)
importedRepoPath, err := locator.GetPath(importedRepoProto)
require.NoError(t, err)
defer os.RemoveAll(importedRepoPath)
diff --git a/internal/gitaly/service/repository/fetch.go b/internal/gitaly/service/repository/fetch.go
index 0a10f31a2..93b5f9458 100644
--- a/internal/gitaly/service/repository/fetch.go
+++ b/internal/gitaly/service/repository/fetch.go
@@ -22,7 +22,7 @@ func (s *server) FetchSourceBranch(ctx context.Context, req *gitalypb.FetchSourc
return nil, helper.ErrInvalidArgument(err)
}
- targetRepo := localrepo.New(req.GetRepository(), s.cfg)
+ targetRepo := localrepo.New(s.gitCmdFactory, req.GetRepository(), s.cfg)
sourceRepo, err := remoterepo.New(ctx, req.GetSourceRepository(), s.conns)
if err != nil {
diff --git a/internal/gitaly/service/repository/fetch_remote.go b/internal/gitaly/service/repository/fetch_remote.go
index b82f61d66..806d2836b 100644
--- a/internal/gitaly/service/repository/fetch_remote.go
+++ b/internal/gitaly/service/repository/fetch_remote.go
@@ -42,7 +42,7 @@ func (s *server) FetchRemote(ctx context.Context, req *gitalypb.FetchRemoteReque
opts.Tags = localrepo.FetchOptsTagsNone
}
- repo := localrepo.New(req.GetRepository(), s.cfg)
+ repo := localrepo.New(s.gitCmdFactory, req.GetRepository(), s.cfg)
remoteName := req.GetRemote()
if params := req.GetRemoteParams(); params != nil {
diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go
index 4a64615c6..554986789 100644
--- a/internal/gitaly/service/repository/fetch_remote_test.go
+++ b/internal/gitaly/service/repository/fetch_remote_test.go
@@ -83,15 +83,17 @@ func TestFetchRemote_withDefaultRefmaps(t *testing.T) {
client, conn := newRepositoryClient(t, serverSocketPath)
defer conn.Close()
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+
sourceRepoProto, sourceRepoPath, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- sourceRepo := localrepo.New(sourceRepoProto, config.Config)
+ sourceRepo := localrepo.New(gitCmdFactory, sourceRepoProto, config.Config)
targetRepoProto, targetRepoPath := copyRepoWithNewRemote(t, sourceRepoProto, locator, "my-remote")
defer func() {
require.NoError(t, os.RemoveAll(targetRepoPath))
}()
- targetRepo := localrepo.New(targetRepoProto, config.Config)
+ targetRepo := localrepo.New(gitCmdFactory, targetRepoProto, config.Config)
port, stopGitServer := testhelper.GitServer(t, config.Config, sourceRepoPath, nil)
defer func() { require.NoError(t, stopGitServer()) }()
@@ -215,7 +217,7 @@ func TestFetchRemote_prune(t *testing.T) {
defer func() {
require.NoError(t, os.RemoveAll(targetRepoPath))
}()
- targetRepo := localrepo.New(targetRepoProto, config.Config)
+ targetRepo := localrepo.New(git.NewExecCommandFactory(config.Config), targetRepoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go
index 60c1f0783..731cab886 100644
--- a/internal/gitaly/service/repository/fetch_test.go
+++ b/internal/gitaly/service/repository/fetch_test.go
@@ -40,7 +40,7 @@ func TestFetchSourceBranchSourceRepositorySuccess(t *testing.T) {
targetRepoProto, _, cleanup := newTestRepo(t, locator, "fetch-source-target.git")
defer cleanup()
- targetRepo := localrepo.New(targetRepoProto, config.Config)
+ targetRepo := localrepo.New(git.NewExecCommandFactory(config.Config), targetRepoProto, config.Config)
sourceRepo, sourcePath, cleanup := newTestRepo(t, locator, "fetch-source-source.git")
defer cleanup()
@@ -82,7 +82,7 @@ func TestFetchSourceBranchSameRepositorySuccess(t *testing.T) {
repoProto, repoPath, cleanup := newTestRepo(t, locator, "fetch-source-source.git")
defer cleanup()
- repo := localrepo.New(repoProto, config.Config)
+ repo := localrepo.New(git.NewExecCommandFactory(config.Config), repoProto, config.Config)
sourceBranch := "fetch-source-branch-test-branch"
newCommitID := testhelper.CreateCommit(t, repoPath, sourceBranch, nil)
diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go
index 5dc274964..b94e1ed11 100644
--- a/internal/gitaly/service/repository/gc_test.go
+++ b/internal/gitaly/service/repository/gc_test.go
@@ -59,7 +59,7 @@ func TestGarbageCollectCommitGraph(t *testing.T) {
require.NoError(t, err)
defer cfgF.Close()
- cfg, err := localrepo.New(testRepo, config.Config).Config().GetRegexp(ctx, "core.commitgraph", git.ConfigGetRegexpOpts{})
+ cfg, err := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config).Config().GetRegexp(ctx, "core.commitgraph", git.ConfigGetRegexpOpts{})
require.NoError(t, err)
require.Equal(t, []git.ConfigPair{{Key: "core.commitgraph", Value: "true"}}, cfg)
}
diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go
index ad13386da..4428fc12d 100644
--- a/internal/gitaly/service/repository/midx_test.go
+++ b/internal/gitaly/service/repository/midx_test.go
@@ -47,7 +47,7 @@ func TestMidxWrite(t *testing.T) {
require.NoError(t, err)
defer cfgF.Close()
- cfg, err := localrepo.New(testRepo, config.Config).Config().GetRegexp(ctx, "core.multipackindex", git.ConfigGetRegexpOpts{})
+ cfg, err := localrepo.New(git.NewExecCommandFactory(config.Config), testRepo, config.Config).Config().GetRegexp(ctx, "core.multipackindex", git.ConfigGetRegexpOpts{})
require.NoError(t, err)
require.Equal(t, []git.ConfigPair{{Key: "core.multipackindex", Value: "true"}}, cfg)
}
diff --git a/internal/gitaly/service/repository/repository.go b/internal/gitaly/service/repository/repository.go
index 9c53c6004..6e0ac7b37 100644
--- a/internal/gitaly/service/repository/repository.go
+++ b/internal/gitaly/service/repository/repository.go
@@ -26,7 +26,7 @@ func (s *server) RepositoryExists(ctx context.Context, in *gitalypb.RepositoryEx
}
func (s *server) HasLocalBranches(ctx context.Context, in *gitalypb.HasLocalBranchesRequest) (*gitalypb.HasLocalBranchesResponse, error) {
- hasBranches, err := localrepo.New(in.Repository, s.cfg).HasBranches(ctx)
+ hasBranches, err := localrepo.New(s.gitCmdFactory, in.Repository, s.cfg).HasBranches(ctx)
if err != nil {
return nil, helper.ErrInternal(err)
}
diff --git a/internal/gitaly/service/wiki/delete_page_test.go b/internal/gitaly/service/wiki/delete_page_test.go
index 93a348d7c..8b5ea726e 100644
--- a/internal/gitaly/service/wiki/delete_page_test.go
+++ b/internal/gitaly/service/wiki/delete_page_test.go
@@ -15,7 +15,7 @@ import (
func TestSuccessfulWikiDeletePageRequest(t *testing.T) {
wikiRepoProto, wikiRepoPath, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- wikiRepo := localrepo.New(wikiRepoProto, config.Config)
+ wikiRepo := localrepo.New(git.NewExecCommandFactory(config.Config), wikiRepoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/gitaly/service/wiki/testhelper_test.go b/internal/gitaly/service/wiki/testhelper_test.go
index 22728debb..e0cd58c12 100644
--- a/internal/gitaly/service/wiki/testhelper_test.go
+++ b/internal/gitaly/service/wiki/testhelper_test.go
@@ -199,7 +199,7 @@ func createTestWikiPage(t *testing.T, locator storage.Locator, client gitalypb.W
writeWikiPage(t, client, wikiRepoProto, opts)
head1ID := testhelper.MustRunCommand(t, nil, "git", "-C", wikiRepoPath, "show", "--format=format:%H", "--no-patch", "HEAD")
- wikiRepo := localrepo.New(wikiRepoProto, config.Config)
+ wikiRepo := localrepo.New(git.NewExecCommandFactory(config.Config), wikiRepoProto, config.Config)
pageCommit, err := wikiRepo.ReadCommit(ctx, git.Revision(head1ID))
require.NoError(t, err, "look up git commit after writing a wiki page")
diff --git a/internal/gitaly/service/wiki/update_page_test.go b/internal/gitaly/service/wiki/update_page_test.go
index 46071a671..ddb254d5b 100644
--- a/internal/gitaly/service/wiki/update_page_test.go
+++ b/internal/gitaly/service/wiki/update_page_test.go
@@ -16,7 +16,7 @@ import (
func TestSuccessfulWikiUpdatePageRequest(t *testing.T) {
wikiRepoProto, wikiRepoPath, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- wikiRepo := localrepo.New(wikiRepoProto, config.Config)
+ wikiRepo := localrepo.New(git.NewExecCommandFactory(config.Config), wikiRepoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/gitaly/service/wiki/write_page_test.go b/internal/gitaly/service/wiki/write_page_test.go
index 7ae0cbbbd..d48102010 100644
--- a/internal/gitaly/service/wiki/write_page_test.go
+++ b/internal/gitaly/service/wiki/write_page_test.go
@@ -16,7 +16,7 @@ import (
func TestSuccessfulWikiWritePageRequest(t *testing.T) {
wikiRepoProto, wikiRepoPath, cleanupFunc := setupWikiRepo(t)
defer cleanupFunc()
- wikiRepo := localrepo.New(wikiRepoProto, config.Config)
+ wikiRepo := localrepo.New(git.NewExecCommandFactory(config.Config), wikiRepoProto, config.Config)
ctx, cancel := testhelper.Context()
defer cancel()