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-27 10:28:12 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2021-02-03 16:28:39 +0300
commitc43c0be3f02bb842008d92b4b388cf0c97cec204 (patch)
treea710f0c54dbdc8aa4897d7bcd7eb2967576b9ee0
parent619a44e3b43e1b8acbcb596fd47d5c1614224384 (diff)
Injection of the git.CommandFactory into catfile package
As we are abstracting dependencies required to create a git command we introduced git.CommandFactory interface that is in duty of creation of the git commands. The catfile package used across different services and as a first step we provide factory as an additional constructor parameter. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
-rw-r--r--cmd/gitaly-git2go/submodule_test.go2
-rw-r--r--internal/git/catfile/batch.go4
-rw-r--r--internal/git/catfile/batchcheck.go4
-rw-r--r--internal/git/catfile/catfile.go12
-rw-r--r--internal/git/catfile/catfile_test.go15
-rw-r--r--internal/git/log/commit.go8
-rw-r--r--internal/git/log/commit_test.go5
-rw-r--r--internal/git/log/last_commit.go2
-rw-r--r--internal/git/log/log.go4
-rw-r--r--internal/git/log/tag_test.go3
-rw-r--r--internal/git/updateref/updateref_test.go30
-rw-r--r--internal/gitaly/service/blob/get_blob.go2
-rw-r--r--internal/gitaly/service/blob/get_blobs.go2
-rw-r--r--internal/gitaly/service/blob/server.go10
-rw-r--r--internal/gitaly/service/blob/testhelper_test.go3
-rw-r--r--internal/gitaly/service/cleanup/apply_bfg_object_map_stream.go2
-rw-r--r--internal/gitaly/service/cleanup/apply_bfg_object_map_stream_test.go2
-rw-r--r--internal/gitaly/service/cleanup/notifier/notifier.go4
-rw-r--r--internal/gitaly/service/cleanup/server.go8
-rw-r--r--internal/gitaly/service/cleanup/testhelper_test.go3
-rw-r--r--internal/gitaly/service/commit/between.go2
-rw-r--r--internal/gitaly/service/commit/commit_messages.go2
-rw-r--r--internal/gitaly/service/commit/commit_signatures.go2
-rw-r--r--internal/gitaly/service/commit/commits_by_message.go6
-rw-r--r--internal/gitaly/service/commit/commits_helper.go6
-rw-r--r--internal/gitaly/service/commit/filter_shas_with_signatures.go2
-rw-r--r--internal/gitaly/service/commit/find_all_commits.go6
-rw-r--r--internal/gitaly/service/commit/find_commit.go2
-rw-r--r--internal/gitaly/service/commit/find_commit_test.go3
-rw-r--r--internal/gitaly/service/commit/find_commits.go2
-rw-r--r--internal/gitaly/service/commit/last_commit_for_path.go2
-rw-r--r--internal/gitaly/service/commit/list_commits_by_oid.go2
-rw-r--r--internal/gitaly/service/commit/list_commits_by_ref_name.go2
-rw-r--r--internal/gitaly/service/commit/list_last_commits_for_tree.go2
-rw-r--r--internal/gitaly/service/commit/server.go10
-rw-r--r--internal/gitaly/service/commit/stats.go2
-rw-r--r--internal/gitaly/service/commit/testhelper_test.go3
-rw-r--r--internal/gitaly/service/commit/tree_entries.go2
-rw-r--r--internal/gitaly/service/commit/tree_entry.go2
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts_test.go4
-rw-r--r--internal/gitaly/service/objectpool/link_test.go2
-rw-r--r--internal/gitaly/service/operations/apply_patch_test.go5
-rw-r--r--internal/gitaly/service/operations/branches.go2
-rw-r--r--internal/gitaly/service/operations/branches_test.go4
-rw-r--r--internal/gitaly/service/operations/cherry_pick_test.go23
-rw-r--r--internal/gitaly/service/operations/commit_files_test.go24
-rw-r--r--internal/gitaly/service/operations/merge_test.go20
-rw-r--r--internal/gitaly/service/operations/rebase_test.go16
-rw-r--r--internal/gitaly/service/operations/revert_test.go30
-rw-r--r--internal/gitaly/service/operations/squash_test.go9
-rw-r--r--internal/gitaly/service/operations/submodules_test.go4
-rw-r--r--internal/gitaly/service/operations/tags.go2
-rw-r--r--internal/gitaly/service/operations/tags_test.go8
-rw-r--r--internal/gitaly/service/operations/testhelper_test.go4
-rw-r--r--internal/gitaly/service/operations/update_branches_test.go7
-rw-r--r--internal/gitaly/service/ref/branches.go2
-rw-r--r--internal/gitaly/service/ref/branches_test.go3
-rw-r--r--internal/gitaly/service/ref/list_new_blobs.go2
-rw-r--r--internal/gitaly/service/ref/list_new_commits.go2
-rw-r--r--internal/gitaly/service/ref/refs.go8
-rw-r--r--internal/gitaly/service/ref/refs_test.go10
-rw-r--r--internal/gitaly/service/ref/remote_branches.go2
-rw-r--r--internal/gitaly/service/ref/remote_branches_test.go6
-rw-r--r--internal/gitaly/service/ref/server.go10
-rw-r--r--internal/gitaly/service/ref/tag_messages.go2
-rw-r--r--internal/gitaly/service/ref/testhelper_test.go3
-rw-r--r--internal/gitaly/service/register.go8
-rw-r--r--internal/gitaly/service/remote/fetch_internal_remote_test.go2
-rw-r--r--internal/gitaly/service/repository/apply_gitattributes.go2
-rw-r--r--internal/gitaly/service/repository/archive.go2
-rw-r--r--internal/gitaly/service/repository/create_from_bundle_test.go3
-rw-r--r--internal/gitaly/service/repository/fetch_test.go4
-rw-r--r--internal/gitaly/service/repository/gc.go2
-rw-r--r--internal/gitaly/service/repository/raw_changes.go2
-rw-r--r--internal/gitaly/service/repository/snapshot_test.go5
-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
-rw-r--r--internal/middleware/commandstatshandler/commandstatshandler_test.go3
-rw-r--r--internal/praefect/replicator_test.go2
-rw-r--r--internal/testhelper/testserver/gitaly.go2
82 files changed, 243 insertions, 201 deletions
diff --git a/cmd/gitaly-git2go/submodule_test.go b/cmd/gitaly-git2go/submodule_test.go
index d8379fb17..588f92a55 100644
--- a/cmd/gitaly-git2go/submodule_test.go
+++ b/cmd/gitaly-git2go/submodule_test.go
@@ -102,7 +102,7 @@ func TestSubmodule(t *testing.T) {
}
require.NoError(t, err)
- commit, err := log.GetCommit(ctx, testRepo, git.Revision(response.CommitID))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(response.CommitID))
require.NoError(t, err)
require.Equal(t, commit.Author.Email, testhelper.TestUser.Email)
require.Equal(t, commit.Committer.Email, testhelper.TestUser.Email)
diff --git a/internal/git/catfile/batch.go b/internal/git/catfile/batch.go
index fd5121316..cdb7b9e02 100644
--- a/internal/git/catfile/batch.go
+++ b/internal/git/catfile/batch.go
@@ -33,7 +33,7 @@ type batchProcess struct {
sync.Mutex
}
-func newBatchProcess(ctx context.Context, repo repository.GitRepo) (*batchProcess, error) {
+func newBatchProcess(ctx context.Context, gitCmdFactory git.CommandFactory, repo repository.GitRepo) (*batchProcess, error) {
totalCatfileProcesses.Inc()
b := &batchProcess{}
@@ -45,7 +45,7 @@ func newBatchProcess(ctx context.Context, repo repository.GitRepo) (*batchProces
ctx = correlation.ContextWithCorrelation(ctx, "")
ctx = opentracing.ContextWithSpan(ctx, nil)
- batchCmd, err := git.NewCommand(ctx, repo, nil,
+ batchCmd, err := gitCmdFactory.New(ctx, repo, nil,
git.SubCmd{
Name: "cat-file",
Flags: []git.Option{
diff --git a/internal/git/catfile/batchcheck.go b/internal/git/catfile/batchcheck.go
index 4a6413a90..b1fa8085b 100644
--- a/internal/git/catfile/batchcheck.go
+++ b/internal/git/catfile/batchcheck.go
@@ -20,7 +20,7 @@ type batchCheck struct {
sync.Mutex
}
-func newBatchCheck(ctx context.Context, repo repository.GitRepo) (*batchCheck, error) {
+func newBatchCheck(ctx context.Context, gitCmdFactory git.CommandFactory, repo repository.GitRepo) (*batchCheck, error) {
bc := &batchCheck{}
var stdinReader io.Reader
@@ -31,7 +31,7 @@ func newBatchCheck(ctx context.Context, repo repository.GitRepo) (*batchCheck, e
ctx = correlation.ContextWithCorrelation(ctx, "")
ctx = opentracing.ContextWithSpan(ctx, nil)
- batchCmd, err := git.NewCommand(ctx, repo, nil,
+ batchCmd, err := gitCmdFactory.New(ctx, repo, nil,
git.SubCmd{
Name: "cat-file",
Flags: []git.Option{
diff --git a/internal/git/catfile/catfile.go b/internal/git/catfile/catfile.go
index adbfe2772..15078ead3 100644
--- a/internal/git/catfile/catfile.go
+++ b/internal/git/catfile/catfile.go
@@ -138,14 +138,14 @@ func (c *batch) isClosed() bool {
// New returns a new Batch instance. It is important that ctx gets canceled
// somewhere, because if it doesn't the cat-file processes spawned by
// New() never terminate.
-func New(ctx context.Context, repo repository.GitRepo) (Batch, error) {
+func New(ctx context.Context, gitCmdFactory git.CommandFactory, repo repository.GitRepo) (Batch, error) {
if ctx.Done() == nil {
panic("empty ctx.Done() in catfile.Batch.New()")
}
sessionID := metadata.GetValue(ctx, SessionIDField)
if sessionID == "" {
- c, err := newBatch(ctx, repo)
+ c, err := newBatch(ctx, gitCmdFactory, repo)
if err != nil {
return nil, err
}
@@ -163,7 +163,7 @@ func New(ctx context.Context, repo repository.GitRepo) (Batch, error) {
// if we are using caching, create a fresh context for the new batch
// and initialize the new batch with a cache key and cancel function
cacheCtx, cacheCancel := context.WithCancel(context.Background())
- c, err := newBatch(cacheCtx, repo)
+ c, err := newBatch(cacheCtx, gitCmdFactory, repo)
if err != nil {
cacheCancel()
return nil, err
@@ -197,7 +197,7 @@ type simulatedBatchSpawnError struct{}
func (simulatedBatchSpawnError) Error() string { return "simulated spawn error" }
-func newBatch(ctx context.Context, repo repository.GitRepo) (_ *batch, err error) {
+func newBatch(ctx context.Context, gitCmdFactory git.CommandFactory, repo repository.GitRepo) (_ *batch, err error) {
ctx, cancel := context.WithCancel(ctx)
defer func() {
if err != nil {
@@ -205,12 +205,12 @@ func newBatch(ctx context.Context, repo repository.GitRepo) (_ *batch, err error
}
}()
- b, err := newBatchProcess(ctx, repo)
+ b, err := newBatchProcess(ctx, gitCmdFactory, repo)
if err != nil {
return nil, err
}
- batchCheck, err := newBatchCheck(ctx, repo)
+ batchCheck, err := newBatchCheck(ctx, gitCmdFactory, repo)
if err != nil {
return nil, err
}
diff --git a/internal/git/catfile/catfile_test.go b/internal/git/catfile/catfile_test.go
index 1f7a45a53..8885d4934 100644
--- a/internal/git/catfile/catfile_test.go
+++ b/internal/git/catfile/catfile_test.go
@@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/command"
"gitlab.com/gitlab-org/gitaly/internal/git"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -27,7 +28,7 @@ func TestInfo(t *testing.T) {
testRepository, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- c, err := New(ctx, testRepository)
+ c, err := New(ctx, git.NewExecCommandFactory(config.Cfg{}), testRepository)
require.NoError(t, err)
testCases := []struct {
@@ -63,7 +64,7 @@ func TestBlob(t *testing.T) {
testRepository, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- c, err := New(ctx, testRepository)
+ c, err := New(ctx, git.NewExecCommandFactory(config.Cfg{}), testRepository)
require.NoError(t, err)
gitignoreBytes, err := ioutil.ReadFile("testdata/blob-dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82")
@@ -130,7 +131,7 @@ func TestCommit(t *testing.T) {
testRepository, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- c, err := New(ctx, testRepository)
+ c, err := New(ctx, git.NewExecCommandFactory(config.Cfg{}), testRepository)
require.NoError(t, err)
commitBytes, err := ioutil.ReadFile("testdata/commit-e63f41fe459e62e1228fcef60d7189127aeba95a")
@@ -168,7 +169,7 @@ func TestTag(t *testing.T) {
testRepository, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- c, err := New(ctx, testRepository)
+ c, err := New(ctx, git.NewExecCommandFactory(config.Cfg{}), testRepository)
require.NoError(t, err)
tagBytes, err := ioutil.ReadFile("testdata/tag-a509fa67c27202a2bc9dd5e014b4af7e6063ac76")
@@ -235,7 +236,7 @@ func TestTree(t *testing.T) {
testRepository, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- c, err := New(ctx, testRepository)
+ c, err := New(ctx, git.NewExecCommandFactory(config.Cfg{}), testRepository)
require.NoError(t, err)
treeBytes, err := ioutil.ReadFile("testdata/tree-7e2f26d033ee47cd0745649d1a28277c56197921")
@@ -302,7 +303,7 @@ func TestRepeatedCalls(t *testing.T) {
testRepository, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- c, err := New(ctx, testRepository)
+ c, err := New(ctx, git.NewExecCommandFactory(config.Cfg{}), testRepository)
require.NoError(t, err)
treeOid := git.Revision("7e2f26d033ee47cd0745649d1a28277c56197921")
@@ -417,7 +418,7 @@ func catfileWithFreshSessionID(ctx context.Context, repo *gitalypb.Repository) (
SessionIDField: id,
})
- return New(metadata.NewIncomingContext(ctx, md), repo)
+ return New(metadata.NewIncomingContext(ctx, md), git.NewExecCommandFactory(config.Cfg{}), repo)
}
func waitTrue(callback func() bool) bool {
diff --git a/internal/git/log/commit.go b/internal/git/log/commit.go
index 5a21ce054..26df58957 100644
--- a/internal/git/log/commit.go
+++ b/internal/git/log/commit.go
@@ -20,8 +20,8 @@ import (
// GetCommit tries to resolve revision to a Git commit. Returns nil if
// no object is found at revision.
-func GetCommit(ctx context.Context, repo *gitalypb.Repository, revision git.Revision) (*gitalypb.GitCommit, error) {
- c, err := catfile.New(ctx, repo)
+func GetCommit(ctx context.Context, gitCmdFactory git.CommandFactory, repo *gitalypb.Repository, revision git.Revision) (*gitalypb.GitCommit, error) {
+ c, err := catfile.New(ctx, gitCmdFactory, repo)
if err != nil {
return nil, err
}
@@ -31,8 +31,8 @@ func GetCommit(ctx context.Context, repo *gitalypb.Repository, revision git.Revi
// GetCommitWithTrailers tries to resolve a revision to a Git commit, including
// Git trailers in its output.
-func GetCommitWithTrailers(ctx context.Context, repo *gitalypb.Repository, revision git.Revision) (*gitalypb.GitCommit, error) {
- c, err := catfile.New(ctx, repo)
+func GetCommitWithTrailers(ctx context.Context, gitCmdFactory git.CommandFactory, repo *gitalypb.Repository, revision git.Revision) (*gitalypb.GitCommit, error) {
+ c, err := catfile.New(ctx, gitCmdFactory, repo)
if err != nil {
return nil, err
}
diff --git a/internal/git/log/commit_test.go b/internal/git/log/commit_test.go
index 189a06b99..95bb991b4 100644
--- a/internal/git/log/commit_test.go
+++ b/internal/git/log/commit_test.go
@@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/catfile"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc/metadata"
@@ -151,7 +152,7 @@ func TestGetCommitCatfile(t *testing.T) {
},
}
- c, err := catfile.New(ctx, testRepo)
+ c, err := catfile.New(ctx, git.NewExecCommandFactory(config.Config), testRepo)
require.NoError(t, err)
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
@@ -175,7 +176,7 @@ func TestGetCommitCatfileWithTrailers(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- catfile, err := catfile.New(ctx, testRepo)
+ catfile, err := catfile.New(ctx, git.NewExecCommandFactory(config.Config), testRepo)
require.NoError(t, err)
diff --git a/internal/git/log/last_commit.go b/internal/git/log/last_commit.go
index 4a5b197a1..d15d5ede2 100644
--- a/internal/git/log/last_commit.go
+++ b/internal/git/log/last_commit.go
@@ -31,7 +31,7 @@ func LastCommitForPath(ctx context.Context, batch catfile.Batch, repo *gitalypb.
}
// GitLogCommand returns a Command that executes git log with the given the arguments
-func GitLogCommand(ctx context.Context, repo *gitalypb.Repository, revisions []git.Revision, paths []string, options *gitalypb.GlobalOptions, extraArgs ...git.Option) (*command.Command, error) {
+func GitLogCommand(ctx context.Context, factory git.CommandFactory, repo *gitalypb.Repository, revisions []git.Revision, paths []string, options *gitalypb.GlobalOptions, extraArgs ...git.Option) (*command.Command, error) {
args := make([]string, len(revisions))
for i, revision := range revisions {
args[i] = revision.String()
diff --git a/internal/git/log/log.go b/internal/git/log/log.go
index ed26c6fe7..e83bc4b70 100644
--- a/internal/git/log/log.go
+++ b/internal/git/log/log.go
@@ -23,8 +23,8 @@ type Parser struct {
}
// NewLogParser returns a new Parser
-func NewLogParser(ctx context.Context, repo *gitalypb.Repository, src io.Reader) (*Parser, error) {
- c, err := catfile.New(ctx, repo)
+func NewLogParser(ctx context.Context, gitCmdFactory git.CommandFactory, repo *gitalypb.Repository, src io.Reader) (*Parser, error) {
+ c, err := catfile.New(ctx, gitCmdFactory, repo)
if err != nil {
return nil, err
}
diff --git a/internal/git/log/tag_test.go b/internal/git/log/tag_test.go
index 5d836d742..29121ecec 100644
--- a/internal/git/log/tag_test.go
+++ b/internal/git/log/tag_test.go
@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/catfile"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
)
@@ -47,7 +48,7 @@ func TestGetTag(t *testing.T) {
},
}
- c, err := catfile.New(ctx, testRepo)
+ c, err := catfile.New(ctx, git.NewExecCommandFactory(config.Config), testRepo)
require.NoError(t, err)
for _, testCase := range testCases {
t.Run(testCase.tagName, func(t *testing.T) {
diff --git a/internal/git/updateref/updateref_test.go b/internal/git/updateref/updateref_test.go
index 986748e3a..f183ca652 100644
--- a/internal/git/updateref/updateref_test.go
+++ b/internal/git/updateref/updateref_test.go
@@ -43,7 +43,8 @@ func TestCreate(t *testing.T) {
ctx, testRepo, _, teardown := setup(t)
defer teardown()
- headCommit, err := log.GetCommit(ctx, testRepo, "HEAD")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ headCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "HEAD")
require.NoError(t, err)
updater, err := New(ctx, config.Config, testRepo)
@@ -56,7 +57,7 @@ func TestCreate(t *testing.T) {
require.NoError(t, updater.Wait())
// check the ref was created
- commit, logErr := log.GetCommit(ctx, testRepo, ref.Revision())
+ commit, logErr := log.GetCommit(ctx, gitCmdFactory, testRepo, ref.Revision())
require.NoError(t, logErr)
require.Equal(t, commit.Id, sha, "reference was created with the wrong SHA")
}
@@ -65,7 +66,8 @@ func TestUpdate(t *testing.T) {
ctx, testRepo, _, teardown := setup(t)
defer teardown()
- headCommit, err := log.GetCommit(ctx, testRepo, "HEAD")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ headCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "HEAD")
require.NoError(t, err)
updater, err := New(ctx, config.Config, testRepo)
@@ -75,7 +77,7 @@ func TestUpdate(t *testing.T) {
sha := headCommit.Id
// Sanity check: ensure the ref exists before we start
- commit, logErr := log.GetCommit(ctx, testRepo, ref.Revision())
+ commit, logErr := log.GetCommit(ctx, gitCmdFactory, testRepo, ref.Revision())
require.NoError(t, logErr)
require.NotEqual(t, commit.Id, sha, "%s points to HEAD: %s in the test repository", ref.String(), sha)
@@ -83,17 +85,17 @@ func TestUpdate(t *testing.T) {
require.NoError(t, updater.Wait())
// check the ref was updated
- commit, logErr = log.GetCommit(ctx, testRepo, ref.Revision())
+ commit, logErr = log.GetCommit(ctx, gitCmdFactory, testRepo, ref.Revision())
require.NoError(t, logErr)
require.Equal(t, commit.Id, sha, "reference was not updated")
// since ref has been updated to HEAD, we know that it does not point to HEAD^. So, HEAD^ is an invalid "old value" for updating ref
- parentCommit, err := log.GetCommit(ctx, testRepo, "HEAD^")
+ parentCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "HEAD^")
require.NoError(t, err)
require.Error(t, updater.Update(ref, parentCommit.Id, parentCommit.Id))
// check the ref was not updated
- commit, logErr = log.GetCommit(ctx, testRepo, ref.Revision())
+ commit, logErr = log.GetCommit(ctx, gitCmdFactory, testRepo, ref.Revision())
require.NoError(t, logErr)
require.NotEqual(t, commit.Id, parentCommit.Id, "reference was updated when it shouldn't have been")
}
@@ -111,7 +113,7 @@ func TestDelete(t *testing.T) {
require.NoError(t, updater.Wait())
// check the ref was removed
- _, err = log.GetCommit(ctx, testRepo, ref.Revision())
+ _, err = log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, ref.Revision())
require.True(t, log.IsNotFound(err), "expected 'not found' error got %v", err)
}
@@ -119,7 +121,7 @@ func TestBulkOperation(t *testing.T) {
ctx, testRepo, _, teardown := setup(t)
defer teardown()
- headCommit, err := log.GetCommit(ctx, testRepo, "HEAD")
+ headCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, "HEAD")
require.NoError(t, err)
updater, err := New(ctx, config.Config, testRepo)
@@ -141,7 +143,8 @@ func TestContextCancelAbortsRefChanges(t *testing.T) {
ctx, testRepo, _, teardown := setup(t)
defer teardown()
- headCommit, err := log.GetCommit(ctx, testRepo, "HEAD")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ headCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "HEAD")
require.NoError(t, err)
childCtx, childCancel := context.WithCancel(ctx)
@@ -157,7 +160,7 @@ func TestContextCancelAbortsRefChanges(t *testing.T) {
require.Error(t, updater.Wait())
// check the ref doesn't exist
- _, err = log.GetCommit(ctx, testRepo, ref.Revision())
+ _, err = log.GetCommit(ctx, gitCmdFactory, testRepo, ref.Revision())
require.True(t, log.IsNotFound(err), "expected 'not found' error got %v", err)
}
@@ -168,7 +171,8 @@ func TestUpdater_closingStdinAbortsChanges(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- headCommit, err := log.GetCommit(ctx, testRepo, "HEAD")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ headCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "HEAD")
require.NoError(t, err)
ref := git.ReferenceName("refs/heads/shouldnotexist")
@@ -186,6 +190,6 @@ func TestUpdater_closingStdinAbortsChanges(t *testing.T) {
// ... but as we now use explicit transactional behaviour, this is no
// longer the case.
- _, err = log.GetCommit(ctx, testRepo, ref.Revision())
+ _, err = log.GetCommit(ctx, gitCmdFactory, testRepo, ref.Revision())
require.True(t, log.IsNotFound(err), "expected 'not found' error got %v", err)
}
diff --git a/internal/gitaly/service/blob/get_blob.go b/internal/gitaly/service/blob/get_blob.go
index bd82cd4c6..1f1d7f38e 100644
--- a/internal/gitaly/service/blob/get_blob.go
+++ b/internal/gitaly/service/blob/get_blob.go
@@ -20,7 +20,7 @@ func (s *server) GetBlob(in *gitalypb.GetBlobRequest, stream gitalypb.BlobServic
return status.Errorf(codes.InvalidArgument, "GetBlob: %v", err)
}
- c, err := catfile.New(stream.Context(), in.Repository)
+ c, err := catfile.New(stream.Context(), s.gitCmdFactory, in.Repository)
if err != nil {
return status.Errorf(codes.Internal, "GetBlob: %v", err)
}
diff --git a/internal/gitaly/service/blob/get_blobs.go b/internal/gitaly/service/blob/get_blobs.go
index 0fdb0800e..2dcf4122f 100644
--- a/internal/gitaly/service/blob/get_blobs.go
+++ b/internal/gitaly/service/blob/get_blobs.go
@@ -144,7 +144,7 @@ func (s *server) GetBlobs(req *gitalypb.GetBlobsRequest, stream gitalypb.BlobSer
return err
}
- c, err := catfile.New(stream.Context(), req.Repository)
+ c, err := catfile.New(stream.Context(), s.gitCmdFactory, req.Repository)
if err != nil {
return err
}
diff --git a/internal/gitaly/service/blob/server.go b/internal/gitaly/service/blob/server.go
index f1c77dd4f..07d414c31 100644
--- a/internal/gitaly/service/blob/server.go
+++ b/internal/gitaly/service/blob/server.go
@@ -1,17 +1,19 @@
package blob
import (
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
type server struct {
- ruby *rubyserver.Server
- locator storage.Locator
+ ruby *rubyserver.Server
+ locator storage.Locator
+ gitCmdFactory git.CommandFactory
}
// NewServer creates a new instance of a grpc BlobServer
-func NewServer(rs *rubyserver.Server, locator storage.Locator) gitalypb.BlobServiceServer {
- return &server{ruby: rs, locator: locator}
+func NewServer(rs *rubyserver.Server, locator storage.Locator, gitCmdFactory git.CommandFactory) gitalypb.BlobServiceServer {
+ return &server{ruby: rs, locator: locator, gitCmdFactory: gitCmdFactory}
}
diff --git a/internal/gitaly/service/blob/testhelper_test.go b/internal/gitaly/service/blob/testhelper_test.go
index 4452c4b9d..3abc670c6 100644
--- a/internal/gitaly/service/blob/testhelper_test.go
+++ b/internal/gitaly/service/blob/testhelper_test.go
@@ -5,6 +5,7 @@ import (
"testing"
log "github.com/sirupsen/logrus"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/internal/storage"
@@ -42,7 +43,7 @@ func testMain(m *testing.M) int {
func runBlobServer(t *testing.T, locator storage.Locator) (func(), string) {
srv := testhelper.NewServer(t, nil, nil)
- gitalypb.RegisterBlobServiceServer(srv.GrpcServer(), NewServer(rubyServer, locator))
+ gitalypb.RegisterBlobServiceServer(srv.GrpcServer(), NewServer(rubyServer, locator, git.NewExecCommandFactory(config.Config)))
reflection.Register(srv.GrpcServer())
srv.Start(t)
diff --git a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream.go b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream.go
index e4a53802d..b6820cd73 100644
--- a/internal/gitaly/service/cleanup/apply_bfg_object_map_stream.go
+++ b/internal/gitaly/service/cleanup/apply_bfg_object_map_stream.go
@@ -40,7 +40,7 @@ func (s *server) ApplyBfgObjectMapStream(server gitalypb.CleanupService_ApplyBfg
reader := &bfgStreamReader{firstRequest: firstRequest, server: server}
chunker := chunk.New(&bfgStreamWriter{server: server})
- notifier, err := notifier.New(ctx, repo, chunker)
+ notifier, err := notifier.New(ctx, s.gitCmdFactory, repo, chunker)
if err != nil {
return helper.ErrInternal(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 0f825c143..b7f302b75 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
@@ -31,7 +31,7 @@ func TestApplyBfgObjectMapStreamSuccess(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- headCommit, err := log.GetCommit(ctx, testRepo, "HEAD")
+ headCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, "HEAD")
require.NoError(t, err)
// A known blob: the CHANGELOG in the test repository
diff --git a/internal/gitaly/service/cleanup/notifier/notifier.go b/internal/gitaly/service/cleanup/notifier/notifier.go
index 15866ae54..865a16e91 100644
--- a/internal/gitaly/service/cleanup/notifier/notifier.go
+++ b/internal/gitaly/service/cleanup/notifier/notifier.go
@@ -17,8 +17,8 @@ type Notifier struct {
}
// New instantiates a new Notifier
-func New(ctx context.Context, repo *gitalypb.Repository, chunker *chunk.Chunker) (*Notifier, error) {
- catfile, err := catfile.New(ctx, repo)
+func New(ctx context.Context, gitCmdFactory git.CommandFactory, repo *gitalypb.Repository, chunker *chunk.Chunker) (*Notifier, error) {
+ catfile, err := catfile.New(ctx, gitCmdFactory, repo)
if err != nil {
return nil, err
}
diff --git a/internal/gitaly/service/cleanup/server.go b/internal/gitaly/service/cleanup/server.go
index 05ef045f1..7d58ad4b1 100644
--- a/internal/gitaly/service/cleanup/server.go
+++ b/internal/gitaly/service/cleanup/server.go
@@ -1,15 +1,17 @@
package cleanup
import (
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
type server struct {
- cfg config.Cfg
+ cfg config.Cfg
+ gitCmdFactory git.CommandFactory
}
// NewServer creates a new instance of a grpc CleanupServer
-func NewServer(cfg config.Cfg) gitalypb.CleanupServiceServer {
- return &server{cfg: cfg}
+func NewServer(cfg config.Cfg, gitCmdFactory git.CommandFactory) gitalypb.CleanupServiceServer {
+ return &server{cfg: cfg, gitCmdFactory: gitCmdFactory}
}
diff --git a/internal/gitaly/service/cleanup/testhelper_test.go b/internal/gitaly/service/cleanup/testhelper_test.go
index caae36f60..d26aa475d 100644
--- a/internal/gitaly/service/cleanup/testhelper_test.go
+++ b/internal/gitaly/service/cleanup/testhelper_test.go
@@ -4,6 +4,7 @@ import (
"os"
"testing"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/hook"
hookservice "gitlab.com/gitlab-org/gitaly/internal/gitaly/service/hook"
@@ -30,7 +31,7 @@ func runCleanupServiceServer(t *testing.T, cfg config.Cfg) (string, func()) {
srv := testhelper.NewServer(t, nil, nil, testhelper.WithInternalSocket(cfg))
locator := config.NewLocator(cfg)
- gitalypb.RegisterCleanupServiceServer(srv.GrpcServer(), NewServer(cfg))
+ gitalypb.RegisterCleanupServiceServer(srv.GrpcServer(), NewServer(cfg, git.NewExecCommandFactory(cfg)))
gitalypb.RegisterHookServiceServer(srv.GrpcServer(), hookservice.NewServer(cfg, hook.NewManager(locator, transaction.NewManager(cfg), hook.GitlabAPIStub, cfg)))
reflection.Register(srv.GrpcServer())
diff --git a/internal/gitaly/service/commit/between.go b/internal/gitaly/service/commit/between.go
index 2a424ab48..075a44e03 100644
--- a/internal/gitaly/service/commit/between.go
+++ b/internal/gitaly/service/commit/between.go
@@ -31,7 +31,7 @@ func (s *server) CommitsBetween(in *gitalypb.CommitsBetweenRequest, stream gital
sender := &commitsBetweenSender{stream: stream}
revisionRange := fmt.Sprintf("%s..%s", in.GetFrom(), in.GetTo())
- if err := sendCommits(stream.Context(), sender, in.GetRepository(), []string{revisionRange}, nil, nil, git.Flag{Name: "--reverse"}); err != nil {
+ if err := sendCommits(stream.Context(), sender, s.gitCmdFactory, in.GetRepository(), []string{revisionRange}, nil, nil, git.Flag{Name: "--reverse"}); err != nil {
return helper.ErrInternal(err)
}
diff --git a/internal/gitaly/service/commit/commit_messages.go b/internal/gitaly/service/commit/commit_messages.go
index a8c17c57e..d6229c1c8 100644
--- a/internal/gitaly/service/commit/commit_messages.go
+++ b/internal/gitaly/service/commit/commit_messages.go
@@ -26,7 +26,7 @@ func (s *server) GetCommitMessages(request *gitalypb.GetCommitMessagesRequest, s
func (s *server) getAndStreamCommitMessages(request *gitalypb.GetCommitMessagesRequest, stream gitalypb.CommitService_GetCommitMessagesServer) error {
ctx := stream.Context()
- c, err := catfile.New(ctx, request.GetRepository())
+ c, err := catfile.New(ctx, s.gitCmdFactory, request.GetRepository())
if err != nil {
return err
}
diff --git a/internal/gitaly/service/commit/commit_signatures.go b/internal/gitaly/service/commit/commit_signatures.go
index 4446bce99..15ec9ab80 100644
--- a/internal/gitaly/service/commit/commit_signatures.go
+++ b/internal/gitaly/service/commit/commit_signatures.go
@@ -29,7 +29,7 @@ func (s *server) GetCommitSignatures(request *gitalypb.GetCommitSignaturesReques
func (s *server) getCommitSignatures(request *gitalypb.GetCommitSignaturesRequest, stream gitalypb.CommitService_GetCommitSignaturesServer) error {
ctx := stream.Context()
- c, err := catfile.New(ctx, request.GetRepository())
+ c, err := catfile.New(ctx, s.gitCmdFactory, request.GetRepository())
if err != nil {
return helper.ErrInternal(err)
}
diff --git a/internal/gitaly/service/commit/commits_by_message.go b/internal/gitaly/service/commit/commits_by_message.go
index 9a2388202..ef04e9527 100644
--- a/internal/gitaly/service/commit/commits_by_message.go
+++ b/internal/gitaly/service/commit/commits_by_message.go
@@ -28,14 +28,14 @@ func (s *server) CommitsByMessage(in *gitalypb.CommitsByMessageRequest, stream g
return helper.ErrInvalidArgument(err)
}
- if err := commitsByMessage(in, stream); err != nil {
+ if err := s.commitsByMessage(in, stream); err != nil {
return helper.ErrInternal(err)
}
return nil
}
-func commitsByMessage(in *gitalypb.CommitsByMessageRequest, stream gitalypb.CommitService_CommitsByMessageServer) error {
+func (s *server) commitsByMessage(in *gitalypb.CommitsByMessageRequest, stream gitalypb.CommitService_CommitsByMessageServer) error {
ctx := stream.Context()
sender := &commitsByMessageSender{stream: stream}
@@ -65,7 +65,7 @@ func commitsByMessage(in *gitalypb.CommitsByMessageRequest, stream gitalypb.Comm
paths = append(paths, string(path))
}
- return sendCommits(stream.Context(), sender, in.GetRepository(), []string{string(revision)}, paths, in.GetGlobalOptions(), gitLogExtraOptions...)
+ return sendCommits(stream.Context(), sender, s.gitCmdFactory, in.GetRepository(), []string{string(revision)}, paths, in.GetGlobalOptions(), gitLogExtraOptions...)
}
func validateCommitsByMessageRequest(in *gitalypb.CommitsByMessageRequest) error {
diff --git a/internal/gitaly/service/commit/commits_helper.go b/internal/gitaly/service/commit/commits_helper.go
index a81b7c873..17aa143b7 100644
--- a/internal/gitaly/service/commit/commits_helper.go
+++ b/internal/gitaly/service/commit/commits_helper.go
@@ -10,18 +10,18 @@ import (
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
-func sendCommits(ctx context.Context, sender chunk.Sender, repo *gitalypb.Repository, revisionRange []string, paths []string, options *gitalypb.GlobalOptions, extraArgs ...git.Option) error {
+func sendCommits(ctx context.Context, sender chunk.Sender, gitCmdFactory git.CommandFactory, repo *gitalypb.Repository, revisionRange []string, paths []string, options *gitalypb.GlobalOptions, extraArgs ...git.Option) error {
revisions := make([]git.Revision, len(revisionRange))
for i, revision := range revisionRange {
revisions[i] = git.Revision(revision)
}
- cmd, err := log.GitLogCommand(ctx, repo, revisions, paths, options, extraArgs...)
+ cmd, err := log.GitLogCommand(ctx, gitCmdFactory, repo, revisions, paths, options, extraArgs...)
if err != nil {
return err
}
- logParser, err := log.NewLogParser(ctx, repo, cmd)
+ logParser, err := log.NewLogParser(ctx, gitCmdFactory, repo, cmd)
if err != nil {
return err
}
diff --git a/internal/gitaly/service/commit/filter_shas_with_signatures.go b/internal/gitaly/service/commit/filter_shas_with_signatures.go
index 9deef1dfe..4c3e64f4a 100644
--- a/internal/gitaly/service/commit/filter_shas_with_signatures.go
+++ b/internal/gitaly/service/commit/filter_shas_with_signatures.go
@@ -37,7 +37,7 @@ func validateFirstFilterShasWithSignaturesRequest(in *gitalypb.FilterShasWithSig
func (s *server) filterShasWithSignatures(bidi gitalypb.CommitService_FilterShasWithSignaturesServer, firstRequest *gitalypb.FilterShasWithSignaturesRequest) error {
ctx := bidi.Context()
- c, err := catfile.New(ctx, firstRequest.GetRepository())
+ c, err := catfile.New(ctx, s.gitCmdFactory, firstRequest.GetRepository())
if err != nil {
return err
}
diff --git a/internal/gitaly/service/commit/find_all_commits.go b/internal/gitaly/service/commit/find_all_commits.go
index 5e02cad77..43dd4d803 100644
--- a/internal/gitaly/service/commit/find_all_commits.go
+++ b/internal/gitaly/service/commit/find_all_commits.go
@@ -46,7 +46,7 @@ func (s *server) FindAllCommits(in *gitalypb.FindAllCommitsRequest, stream gital
revisions = []string{string(in.GetRevision())}
}
- if err := findAllCommits(in, stream, revisions); err != nil {
+ if err := s.findAllCommits(in, stream, revisions); err != nil {
return helper.ErrInternal(err)
}
@@ -61,7 +61,7 @@ func validateFindAllCommitsRequest(in *gitalypb.FindAllCommitsRequest) error {
return nil
}
-func findAllCommits(in *gitalypb.FindAllCommitsRequest, stream gitalypb.CommitService_FindAllCommitsServer, revisions []string) error {
+func (s *server) findAllCommits(in *gitalypb.FindAllCommitsRequest, stream gitalypb.CommitService_FindAllCommitsServer, revisions []string) error {
sender := &findAllCommitsSender{stream: stream}
var gitLogExtraOptions []git.Option
@@ -80,5 +80,5 @@ func findAllCommits(in *gitalypb.FindAllCommitsRequest, stream gitalypb.CommitSe
gitLogExtraOptions = append(gitLogExtraOptions, git.Flag{Name: "--topo-order"})
}
- return sendCommits(stream.Context(), sender, in.GetRepository(), revisions, nil, nil, gitLogExtraOptions...)
+ return sendCommits(stream.Context(), sender, s.gitCmdFactory, in.GetRepository(), revisions, nil, nil, gitLogExtraOptions...)
}
diff --git a/internal/gitaly/service/commit/find_commit.go b/internal/gitaly/service/commit/find_commit.go
index c5670f956..6db49dc68 100644
--- a/internal/gitaly/service/commit/find_commit.go
+++ b/internal/gitaly/service/commit/find_commit.go
@@ -21,7 +21,7 @@ func (s *server) FindCommit(ctx context.Context, in *gitalypb.FindCommitRequest)
if in.GetTrailers() {
commitGetter = log.GetCommitWithTrailers
}
- commit, err := commitGetter(ctx, repo, git.Revision(revision))
+ commit, err := commitGetter(ctx, s.gitCmdFactory, repo, git.Revision(revision))
if log.IsNotFound(err) {
return &gitalypb.FindCommitResponse{}, nil
}
diff --git a/internal/gitaly/service/commit/find_commit_test.go b/internal/gitaly/service/commit/find_commit_test.go
index 0ebad2de1..d176b73a1 100644
--- a/internal/gitaly/service/commit/find_commit_test.go
+++ b/internal/gitaly/service/commit/find_commit_test.go
@@ -11,6 +11,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/helper"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -40,7 +41,7 @@ func TestSuccessfulFindCommitRequest(t *testing.T) {
Message: bigMessage,
ParentID: "60ecb67744cb56576c30214ff52294f8ce2def98",
})
- bigCommit, err := log.GetCommit(ctx, testRepo, git.Revision(bigCommitID))
+ bigCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(bigCommitID))
require.NoError(t, err)
testCases := []struct {
diff --git a/internal/gitaly/service/commit/find_commits.go b/internal/gitaly/service/commit/find_commits.go
index 99406ef6d..ebcbed34b 100644
--- a/internal/gitaly/service/commit/find_commits.go
+++ b/internal/gitaly/service/commit/find_commits.go
@@ -55,7 +55,7 @@ func (s *server) findCommits(ctx context.Context, req *gitalypb.FindCommitsReque
return fmt.Errorf("error when creating git log command: %v", err)
}
- batch, err := catfile.New(ctx, req.GetRepository())
+ batch, err := catfile.New(ctx, s.gitCmdFactory, req.GetRepository())
if err != nil {
return fmt.Errorf("creating catfile: %v", err)
}
diff --git a/internal/gitaly/service/commit/last_commit_for_path.go b/internal/gitaly/service/commit/last_commit_for_path.go
index 9303b435d..037e6a4a0 100644
--- a/internal/gitaly/service/commit/last_commit_for_path.go
+++ b/internal/gitaly/service/commit/last_commit_for_path.go
@@ -30,7 +30,7 @@ func (s *server) lastCommitForPath(ctx context.Context, in *gitalypb.LastCommitF
}
repo := in.GetRepository()
- c, err := catfile.New(ctx, repo)
+ c, err := catfile.New(ctx, s.gitCmdFactory, repo)
if err != nil {
return nil, err
}
diff --git a/internal/gitaly/service/commit/list_commits_by_oid.go b/internal/gitaly/service/commit/list_commits_by_oid.go
index c17e644f4..1d5efb6c2 100644
--- a/internal/gitaly/service/commit/list_commits_by_oid.go
+++ b/internal/gitaly/service/commit/list_commits_by_oid.go
@@ -30,7 +30,7 @@ func init() {
func (s *server) ListCommitsByOid(in *gitalypb.ListCommitsByOidRequest, stream gitalypb.CommitService_ListCommitsByOidServer) error {
ctx := stream.Context()
- c, err := catfile.New(ctx, in.Repository)
+ c, err := catfile.New(ctx, s.gitCmdFactory, in.Repository)
if err != nil {
return err
}
diff --git a/internal/gitaly/service/commit/list_commits_by_ref_name.go b/internal/gitaly/service/commit/list_commits_by_ref_name.go
index 82b05c550..6db277149 100644
--- a/internal/gitaly/service/commit/list_commits_by_ref_name.go
+++ b/internal/gitaly/service/commit/list_commits_by_ref_name.go
@@ -13,7 +13,7 @@ import (
func (s *server) ListCommitsByRefName(in *gitalypb.ListCommitsByRefNameRequest, stream gitalypb.CommitService_ListCommitsByRefNameServer) error {
ctx := stream.Context()
- c, err := catfile.New(ctx, in.Repository)
+ c, err := catfile.New(ctx, s.gitCmdFactory, in.Repository)
if err != nil {
return helper.ErrInternal(err)
}
diff --git a/internal/gitaly/service/commit/list_last_commits_for_tree.go b/internal/gitaly/service/commit/list_last_commits_for_tree.go
index 46962a544..0cb6f480f 100644
--- a/internal/gitaly/service/commit/list_last_commits_for_tree.go
+++ b/internal/gitaly/service/commit/list_last_commits_for_tree.go
@@ -45,7 +45,7 @@ func (s *server) listLastCommitsForTree(in *gitalypb.ListLastCommitsForTreeReque
ctx := stream.Context()
repo := in.GetRepository()
- c, err := catfile.New(ctx, repo)
+ c, err := catfile.New(ctx, s.gitCmdFactory, repo)
if err != nil {
return err
}
diff --git a/internal/gitaly/service/commit/server.go b/internal/gitaly/service/commit/server.go
index 3a923fc73..dd981b6d8 100644
--- a/internal/gitaly/service/commit/server.go
+++ b/internal/gitaly/service/commit/server.go
@@ -1,6 +1,7 @@
package commit
import (
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/ref"
"gitlab.com/gitlab-org/gitaly/internal/storage"
@@ -8,8 +9,9 @@ import (
)
type server struct {
- locator storage.Locator
- cfg config.Cfg
+ locator storage.Locator
+ cfg config.Cfg
+ gitCmdFactory git.CommandFactory
}
var (
@@ -17,6 +19,6 @@ var (
)
// NewServer creates a new instance of a grpc CommitServiceServer
-func NewServer(cfg config.Cfg, locator storage.Locator) gitalypb.CommitServiceServer {
- return &server{cfg: cfg, locator: locator}
+func NewServer(cfg config.Cfg, locator storage.Locator, gitCmdFactory git.CommandFactory) gitalypb.CommitServiceServer {
+ return &server{cfg: cfg, locator: locator, gitCmdFactory: gitCmdFactory}
}
diff --git a/internal/gitaly/service/commit/stats.go b/internal/gitaly/service/commit/stats.go
index 91bf82775..7f59d51ee 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) {
- commit, err := log.GetCommit(ctx, in.Repository, git.Revision(in.Revision))
+ commit, err := log.GetCommit(ctx, s.gitCmdFactory, in.Repository, git.Revision(in.Revision))
if err != nil {
return nil, err
}
diff --git a/internal/gitaly/service/commit/testhelper_test.go b/internal/gitaly/service/commit/testhelper_test.go
index 293bd49bc..b8d4a3a62 100644
--- a/internal/gitaly/service/commit/testhelper_test.go
+++ b/internal/gitaly/service/commit/testhelper_test.go
@@ -6,6 +6,7 @@ import (
"testing"
"github.com/golang/protobuf/ptypes/timestamp"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -33,7 +34,7 @@ func startTestServices(t testing.TB) (*grpc.Server, string) {
t.Fatal("failed to start server")
}
- gitalypb.RegisterCommitServiceServer(server, NewServer(config.Config, config.NewLocator(config.Config)))
+ gitalypb.RegisterCommitServiceServer(server, NewServer(config.Config, config.NewLocator(config.Config), git.NewExecCommandFactory(config.Config)))
reflection.Register(server)
go server.Serve(listener)
diff --git a/internal/gitaly/service/commit/tree_entries.go b/internal/gitaly/service/commit/tree_entries.go
index 4e873627a..3bd5a414d 100644
--- a/internal/gitaly/service/commit/tree_entries.go
+++ b/internal/gitaly/service/commit/tree_entries.go
@@ -99,7 +99,7 @@ func (s *server) GetTreeEntries(in *gitalypb.GetTreeEntriesRequest, stream gital
return status.Errorf(codes.InvalidArgument, "TreeEntry: %v", err)
}
- c, err := catfile.New(stream.Context(), in.Repository)
+ c, err := catfile.New(stream.Context(), s.gitCmdFactory, in.Repository)
if err != nil {
return err
}
diff --git a/internal/gitaly/service/commit/tree_entry.go b/internal/gitaly/service/commit/tree_entry.go
index 4ec89c611..f5b0c6da5 100644
--- a/internal/gitaly/service/commit/tree_entry.go
+++ b/internal/gitaly/service/commit/tree_entry.go
@@ -125,7 +125,7 @@ func (s *server) TreeEntry(in *gitalypb.TreeEntryRequest, stream gitalypb.Commit
requestPath = strings.TrimRight(requestPath, "/")
}
- c, err := catfile.New(stream.Context(), in.Repository)
+ c, err := catfile.New(stream.Context(), s.gitCmdFactory, in.Repository)
if err != nil {
return err
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
index e32c7fb53..84cdf0183 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
@@ -111,7 +111,7 @@ func testSuccessfulResolveConflictsRequest(t *testing.T, ctx context.Context) {
require.NoError(t, err)
require.Empty(t, r.GetResolutionError())
- headCommit, err := log.GetCommit(ctxOuter, testRepo, git.Revision(sourceBranch))
+ headCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(sourceBranch))
require.NoError(t, err)
require.Contains(t, headCommit.ParentIds, "1450cd639e0bc6721eb02800169e464f212cde06")
require.Contains(t, headCommit.ParentIds, "824be604a34828eb682305f0d963056cfac87b2d")
@@ -172,7 +172,7 @@ func testResolveConflictsStableID(t *testing.T, ctx context.Context) {
require.NoError(t, err)
require.Empty(t, response.GetResolutionError())
- resolvedCommit, err := log.GetCommit(ctx, repo, git.Revision("conflict-resolvable"))
+ resolvedCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), repo, git.Revision("conflict-resolvable"))
require.NoError(t, err)
require.Equal(t, &gitalypb.GitCommit{
Id: "a5ad028fd739d7a054b07c293e77c5b7aecc2435",
diff --git a/internal/gitaly/service/objectpool/link_test.go b/internal/gitaly/service/objectpool/link_test.go
index 215c00a15..320d811e2 100644
--- a/internal/gitaly/service/objectpool/link_test.go
+++ b/internal/gitaly/service/objectpool/link_test.go
@@ -83,7 +83,7 @@ func TestLink(t *testing.T) {
require.NoError(t, err, "error from LinkRepositoryToObjectPool")
- commit, err := log.GetCommit(ctx, testRepo, git.Revision(poolCommitID))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(poolCommitID))
require.NoError(t, err)
require.NotNil(t, commit)
require.Equal(t, poolCommitID, commit.Id)
diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go
index 5056fc4c5..a15f744f1 100644
--- a/internal/gitaly/service/operations/apply_patch_test.go
+++ b/internal/gitaly/service/operations/apply_patch_test.go
@@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/streamio"
@@ -126,7 +127,7 @@ func testSuccessfulUserApplyPatch(t *testing.T, ctx context.Context) {
}
for index, sha := range shas {
- commit, err := log.GetCommit(ctx, testRepo, git.Revision(sha))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(sha))
require.NoError(t, err)
require.NotNil(t, commit)
@@ -177,7 +178,7 @@ func TestUserApplyPatch_stableID(t *testing.T) {
require.NoError(t, err)
require.True(t, response.BranchUpdate.BranchCreated)
- patchedCommit, err := log.GetCommit(ctx, repo, git.Revision("branch"))
+ patchedCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), repo, git.Revision("branch"))
require.NoError(t, err)
require.Equal(t, &gitalypb.GitCommit{
Id: "8cd17acdb54178121167078c78d874d3cc09b216",
diff --git a/internal/gitaly/service/operations/branches.go b/internal/gitaly/service/operations/branches.go
index 07918a422..7fc16bda5 100644
--- a/internal/gitaly/service/operations/branches.go
+++ b/internal/gitaly/service/operations/branches.go
@@ -35,7 +35,7 @@ func (s *Server) UserCreateBranch(ctx context.Context, req *gitalypb.UserCreateB
//
// startPointReference, err := localrepo.New(req.Repository).GetReference(ctx, "refs/heads/"+string(req.StartPoint))
// startPointCommit, err := log.GetCommit(ctx, req.Repository, startPointReference.Target)
- startPointCommit, err := log.GetCommit(ctx, req.Repository, git.Revision(req.StartPoint))
+ startPointCommit, err := log.GetCommit(ctx, s.gitCmdFactory, req.Repository, git.Revision(req.StartPoint))
// END TODO
if err != nil {
return nil, status.Errorf(codes.FailedPrecondition, "revspec '%s' not found", req.StartPoint)
diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go
index 440210b80..7ef37a9e5 100644
--- a/internal/gitaly/service/operations/branches_test.go
+++ b/internal/gitaly/service/operations/branches_test.go
@@ -49,7 +49,7 @@ func TestSuccessfulCreateBranchRequest(t *testing.T) {
defer conn.Close()
startPoint := "c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"
- startPointCommit, err := log.GetCommit(ctx, testRepo, git.Revision(startPoint))
+ startPointCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(startPoint))
require.NoError(t, err)
testCases := []struct {
@@ -315,7 +315,7 @@ func TestSuccessfulCreateBranchRequestWithStartPointRefPrefix(t *testing.T) {
//
//targetCommitOK, err := log.GetCommit(ctx, testRepo, testCase.startPointCommit)
// END TODO
- targetCommitOK, err := log.GetCommit(ctx, testRepo, "1e292f8fedd741b75372e19097c76d327140c312")
+ targetCommitOK, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, "1e292f8fedd741b75372e19097c76d327140c312")
require.NoError(t, err)
response, err := client.UserCreateBranch(ctx, request)
diff --git a/internal/gitaly/service/operations/cherry_pick_test.go b/internal/gitaly/service/operations/cherry_pick_test.go
index 1919639fa..a8637675c 100644
--- a/internal/gitaly/service/operations/cherry_pick_test.go
+++ b/internal/gitaly/service/operations/cherry_pick_test.go
@@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc/codes"
@@ -30,10 +31,11 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) {
destinationBranch := "cherry-picking-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
- masterHeadCommit, err := log.GetCommit(ctxOuter, testRepo, "master")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ masterHeadCommit, err := log.GetCommit(ctxOuter, gitCmdFactory, testRepo, "master")
require.NoError(t, err)
- cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
+ cherryPickedCommit, err := log.GetCommit(ctxOuter, gitCmdFactory, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
require.NoError(t, err)
testRepoCopy, testRepoCopyPath, cleanup := testhelper.NewTestRepo(t) // read-only repo
@@ -156,7 +158,7 @@ func TestSuccessfulUserCherryPickRequest(t *testing.T) {
response, err := client.UserCherryPick(ctx, testCase.request)
require.NoError(t, err)
- headCommit, err := log.GetCommit(ctx, testCase.request.Repository, git.Revision(testCase.request.BranchName))
+ headCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testCase.request.Repository, git.Revision(testCase.request.BranchName))
require.NoError(t, err)
expectedBranchUpdate := testCase.branchUpdate
@@ -197,7 +199,7 @@ func testSuccessfulGitHooksForUserCherryPickRequest(t *testing.T, ctxOuter conte
destinationBranch := "cherry-picking-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
- cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
+ cherryPickedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
require.NoError(t, err)
request := &gitalypb.UserCherryPickRequest{
@@ -244,7 +246,8 @@ func TestUserCherryPick_stableID(t *testing.T) {
destinationBranch := "cherry-picking-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
- commitToPick, err := log.GetCommit(ctx, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ commitToPick, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
require.NoError(t, err)
request := &gitalypb.UserCherryPickRequest{
@@ -264,7 +267,7 @@ func TestUserCherryPick_stableID(t *testing.T) {
require.Empty(t, response.PreReceiveError)
require.Equal(t, response.BranchUpdate.CommitId, "750e8cf248a67a0be1c5e3b891697d72c19af259")
- pickedCommit, err := log.GetCommit(ctx, testRepo, "750e8cf248a67a0be1c5e3b891697d72c19af259")
+ pickedCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "750e8cf248a67a0be1c5e3b891697d72c19af259")
require.NoError(t, err)
require.Equal(t, &gitalypb.GitCommit{
Id: "750e8cf248a67a0be1c5e3b891697d72c19af259",
@@ -305,7 +308,7 @@ func TestFailedUserCherryPickRequestDueToValidations(t *testing.T) {
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
+ cherryPickedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
require.NoError(t, err)
destinationBranch := "cherry-picking-dst"
@@ -388,7 +391,7 @@ func TestFailedUserCherryPickRequestDueToPreReceiveError(t *testing.T) {
destinationBranch := "cherry-picking-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
- cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
+ cherryPickedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
require.NoError(t, err)
request := &gitalypb.UserCherryPickRequest{
@@ -433,7 +436,7 @@ func TestFailedUserCherryPickRequestDueToCreateTreeError(t *testing.T) {
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
// This commit already exists in master
- cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, "4a24d82dbca5c11c61556f3b35ca472b7463187e")
+ cherryPickedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, "4a24d82dbca5c11c61556f3b35ca472b7463187e")
require.NoError(t, err)
request := &gitalypb.UserCherryPickRequest{
@@ -471,7 +474,7 @@ func TestFailedUserCherryPickRequestDueToCommitError(t *testing.T) {
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", sourceBranch, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab")
- cherryPickedCommit, err := log.GetCommit(ctxOuter, testRepo, git.Revision(sourceBranch))
+ cherryPickedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(sourceBranch))
require.NoError(t, err)
request := &gitalypb.UserCherryPickRequest{
diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go
index 87957582f..7ddb0808d 100644
--- a/internal/gitaly/service/operations/commit_files_test.go
+++ b/internal/gitaly/service/operations/commit_files_test.go
@@ -16,6 +16,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
@@ -992,7 +993,7 @@ func testUserCommitFilesStableCommitID(t *testing.T, ctx context.Context) {
{Mode: "100644", Path: "file.txt", Content: "content"},
})
- commit, err := log.GetCommit(ctx, repo, "refs/heads/master")
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), repo, "refs/heads/master")
require.NoError(t, err)
require.Equal(t, &gitalypb.GitCommit{
Id: "4f0ca1fbf05e04dbd5f68d14677034e0afee58ff",
@@ -1102,7 +1103,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 := log.GetCommit(ctx, tc.repo, git.Revision(tc.branchName))
+ headCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), tc.repo, git.Revision(tc.branchName))
require.NoError(t, err)
require.Equal(t, authorName, headCommit.Author.Name)
require.Equal(t, testhelper.TestUser.Name, headCommit.Committer.Name)
@@ -1204,10 +1205,11 @@ func testSuccessfulUserCommitFilesRequestForceCommit(t *testing.T, ctx context.C
targetBranchName := "feature"
startBranchName := []byte("master")
- startBranchCommit, err := log.GetCommit(ctx, testRepo, git.Revision(startBranchName))
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ startBranchCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(startBranchName))
require.NoError(t, err)
- targetBranchCommit, err := log.GetCommit(ctx, testRepo, git.Revision(targetBranchName))
+ targetBranchCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(targetBranchName))
require.NoError(t, err)
mergeBaseOut := testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "merge-base", targetBranchCommit.Id, startBranchCommit.Id)
@@ -1229,7 +1231,7 @@ func testSuccessfulUserCommitFilesRequestForceCommit(t *testing.T, ctx context.C
require.NoError(t, err)
update := resp.GetBranchUpdate()
- newTargetBranchCommit, err := log.GetCommit(ctx, testRepo, git.Revision(targetBranchName))
+ newTargetBranchCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(targetBranchName))
require.NoError(t, err)
require.Equal(t, newTargetBranchCommit.Id, update.CommitId)
@@ -1252,7 +1254,8 @@ func testSuccessfulUserCommitFilesRequestStartSha(t *testing.T, ctx context.Cont
targetBranchName := "new"
- startCommit, err := log.GetCommit(ctx, testRepo, "master")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ startCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "master")
require.NoError(t, err)
headerRequest := headerRequest(testRepo, testhelper.TestUser, targetBranchName, commitFilesMessage)
@@ -1268,7 +1271,7 @@ func testSuccessfulUserCommitFilesRequestStartSha(t *testing.T, ctx context.Cont
require.NoError(t, err)
update := resp.GetBranchUpdate()
- newTargetBranchCommit, err := log.GetCommit(ctx, testRepo, git.Revision(targetBranchName))
+ newTargetBranchCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(targetBranchName))
require.NoError(t, err)
require.Equal(t, newTargetBranchCommit.Id, update.CommitId)
@@ -1311,7 +1314,8 @@ func testSuccessfulUserCommitFilesRemoteRepositoryRequest(setHeader func(header
targetBranchName := "new"
- startCommit, err := log.GetCommit(ctx, testRepo, "master")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ startCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, "master")
require.NoError(t, err)
headerRequest := headerRequest(newRepo, testhelper.TestUser, targetBranchName, commitFilesMessage)
@@ -1328,7 +1332,7 @@ func testSuccessfulUserCommitFilesRemoteRepositoryRequest(setHeader func(header
require.NoError(t, err)
update := resp.GetBranchUpdate()
- newTargetBranchCommit, err := log.GetCommit(ctx, newRepo, git.Revision(targetBranchName))
+ newTargetBranchCommit, err := log.GetCommit(ctx, gitCmdFactory, newRepo, git.Revision(targetBranchName))
require.NoError(t, err)
require.Equal(t, newTargetBranchCommit.Id, update.CommitId)
@@ -1381,7 +1385,7 @@ func testSuccessfulUserCommitFilesRequestWithSpecialCharactersInSignature(t *tes
_, err = stream.CloseAndRecv()
require.NoError(t, err)
- newCommit, err := log.GetCommit(ctx, testRepo, git.Revision(targetBranchName))
+ newCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(targetBranchName))
require.NoError(t, err)
require.Equal(t, tc.author.Name, newCommit.Author.Name, "author name")
diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go
index e201d2501..91cc9e3d5 100644
--- a/internal/gitaly/service/operations/merge_test.go
+++ b/internal/gitaly/service/operations/merge_test.go
@@ -86,7 +86,8 @@ func TestSuccessfulMerge(t *testing.T) {
firstResponse, err := mergeBidi.Recv()
require.NoError(t, err, "receive first response")
- _, err = gitlog.GetCommit(ctx, testRepo, git.Revision(firstResponse.CommitId))
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ _, err = gitlog.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(firstResponse.CommitId))
require.NoError(t, err, "look up git commit before merge is applied")
require.NoError(t, mergeBidi.Send(&gitalypb.UserMergeBranchRequest{Apply: true}), "apply merge")
@@ -99,7 +100,7 @@ func TestSuccessfulMerge(t *testing.T) {
return err
})
- commit, err := gitlog.GetCommit(ctx, testRepo, git.Revision(mergeBranchName))
+ commit, err := gitlog.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(mergeBranchName))
require.NoError(t, err, "look up git commit after call has finished")
require.Equal(t, gitalypb.OperationBranchUpdate{CommitId: commit.Id}, *(secondResponse.BranchUpdate))
@@ -172,7 +173,7 @@ func TestSuccessfulMerge_stableMergeIDs(t *testing.T) {
return err
})
- commit, err := gitlog.GetCommit(ctx, testRepo, git.Revision(mergeBranchName))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(mergeBranchName))
require.NoError(t, err, "look up git commit after call has finished")
require.Equal(t, commit, &gitalypb.GitCommit{
Subject: []byte("Merged by Gitaly"),
@@ -261,7 +262,7 @@ func TestAbortedMerge(t *testing.T) {
require.Equal(t, "", secondResponse.GetBranchUpdate().GetCommitId(), "merge should not have been applied")
require.Error(t, err)
- commit, err := gitlog.GetCommit(ctx, testRepo, git.Revision(mergeBranchName))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(mergeBranchName))
require.NoError(t, err, "look up git commit after call has finished")
require.Equal(t, mergeBranchHeadBefore, commit.Id, "branch should not change when the merge is aborted")
@@ -311,7 +312,7 @@ func TestFailedMergeConcurrentUpdate(t *testing.T) {
require.NoError(t, err, "receive second response")
testhelper.ProtoEqual(t, secondResponse, &gitalypb.UserMergeBranchResponse{})
- commit, err := gitlog.GetCommit(ctx, testRepo, git.Revision(mergeBranchName))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(mergeBranchName))
require.NoError(t, err, "get commit after RPC finished")
require.Equal(t, commit.Id, concurrentCommitID, "RPC should not have trampled concurrent update")
}
@@ -376,7 +377,7 @@ func TestUserMergeBranch_ambiguousReference(t *testing.T) {
return err
})
- commit, err := gitlog.GetCommit(ctx, testRepo, git.Revision("refs/heads/"+mergeBranchName))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision("refs/heads/"+mergeBranchName))
require.NoError(t, err, "look up git commit after call has finished")
require.Equal(t, gitalypb.OperationBranchUpdate{CommitId: commit.Id}, *(response.BranchUpdate))
@@ -752,7 +753,8 @@ func TestSuccessfulUserMergeToRefRequest(t *testing.T) {
FirstParentRef: testCase.firstParentRef,
}
- commitBeforeRefMerge, fetchRefBeforeMergeErr := gitlog.GetCommit(ctx, testRepo, git.Revision(testCase.targetRef))
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ commitBeforeRefMerge, fetchRefBeforeMergeErr := gitlog.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(testCase.targetRef))
if testCase.emptyRef {
require.Error(t, fetchRefBeforeMergeErr, "error when fetching empty ref commit")
} else {
@@ -762,7 +764,7 @@ func TestSuccessfulUserMergeToRefRequest(t *testing.T) {
resp, err := client.UserMergeToRef(ctx, request)
require.NoError(t, err)
- commit, err := gitlog.GetCommit(ctx, testRepo, git.Revision(testCase.targetRef))
+ commit, err := gitlog.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(testCase.targetRef))
require.NoError(t, err, "look up git commit after call has finished")
// Asserts commit parent SHAs
@@ -863,7 +865,7 @@ func TestUserMergeToRef_stableMergeID(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "a04514f4e6b4e272989b39cca1ebdbb670abdfd6", response.CommitId)
- commit, err := gitlog.GetCommit(ctx, testRepo, git.Revision("refs/merge-requests/x/written"))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision("refs/merge-requests/x/written"))
require.NoError(t, err, "look up git commit after call has finished")
require.Equal(t, &gitalypb.GitCommit{
Subject: []byte("Merge message"),
diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go
index 085c71d34..51eeda301 100644
--- a/internal/gitaly/service/operations/rebase_test.go
+++ b/internal/gitaly/service/operations/rebase_test.go
@@ -13,6 +13,7 @@ import (
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/catfile"
gitlog "gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -75,7 +76,7 @@ func TestSuccessfulUserRebaseConfirmableRequest(t *testing.T) {
firstResponse, err := rebaseStream.Recv()
require.NoError(t, err, "receive first response")
- _, err = gitlog.GetCommit(ctx, testRepo, git.Revision(firstResponse.GetRebaseSha()))
+ _, err = gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(firstResponse.GetRebaseSha()))
require.NoError(t, err, "look up git commit before rebase is applied")
applyRequest := buildApplyRequest(true)
@@ -164,7 +165,7 @@ func TestUserRebaseConfirmable_stableCommitIDs(t *testing.T) {
return err
})
- commit, err := gitlog.GetCommit(ctx, testRepo, git.Revision(rebaseBranchName))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(rebaseBranchName))
require.NoError(t, err, "look up git commit")
testhelper.ProtoEqual(t, &gitalypb.GitCommit{
Subject: []byte("Add a directory with many files to allow testing of default 1,000 entry limit"),
@@ -358,7 +359,7 @@ func TestFailedUserRebaseConfirmableDueToApplyBeingFalse(t *testing.T) {
firstResponse, err := rebaseStream.Recv()
require.NoError(t, err, "receive first response")
- _, err = gitlog.GetCommit(ctx, testRepo, git.Revision(firstResponse.GetRebaseSha()))
+ _, err = gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(firstResponse.GetRebaseSha()))
require.NoError(t, err, "look up git commit before rebase is applied")
applyRequest := buildApplyRequest(false)
@@ -411,7 +412,7 @@ func TestFailedUserRebaseConfirmableRequestDueToPreReceiveError(t *testing.T) {
firstResponse, err := rebaseStream.Recv()
require.NoError(t, err, "receive first response")
- _, err = gitlog.GetCommit(ctx, testRepo, git.Revision(firstResponse.GetRebaseSha()))
+ _, err = gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(firstResponse.GetRebaseSha()))
require.NoError(t, err, "look up git commit before rebase is applied")
applyRequest := buildApplyRequest(true)
@@ -518,7 +519,7 @@ func TestRebaseRequestWithDeletedFile(t *testing.T) {
firstResponse, err := rebaseStream.Recv()
require.NoError(t, err, "receive first response")
- _, err = gitlog.GetCommit(ctx, testRepo, git.Revision(firstResponse.GetRebaseSha()))
+ _, err = gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(firstResponse.GetRebaseSha()))
require.NoError(t, err, "look up git commit before rebase is applied")
applyRequest := buildApplyRequest(true)
@@ -573,7 +574,8 @@ func TestRebaseOntoRemoteBranch(t *testing.T) {
rebaseStream, err := client.UserRebaseConfirmable(ctx)
require.NoError(t, err)
- _, err = gitlog.GetCommit(ctx, localRepo, git.Revision(remoteBranchHash))
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ _, err = gitlog.GetCommit(ctx, gitCmdFactory, localRepo, git.Revision(remoteBranchHash))
require.True(t, catfile.IsNotFound(err), "remote commit does not yet exist in local repository")
headerRequest := buildHeaderRequest(localRepo, testhelper.TestUser, "1", localBranch, localBranchHash, remoteRepo, remoteBranch)
@@ -582,7 +584,7 @@ func TestRebaseOntoRemoteBranch(t *testing.T) {
firstResponse, err := rebaseStream.Recv()
require.NoError(t, err, "receive first response")
- _, err = gitlog.GetCommit(ctx, localRepo, git.Revision(remoteBranchHash))
+ _, err = gitlog.GetCommit(ctx, gitCmdFactory, localRepo, git.Revision(remoteBranchHash))
require.NoError(t, err, "remote commit does now exist in local repository")
applyRequest := buildApplyRequest(true)
diff --git a/internal/gitaly/service/operations/revert_test.go b/internal/gitaly/service/operations/revert_test.go
index 6e4b791a3..64c10eb15 100644
--- a/internal/gitaly/service/operations/revert_test.go
+++ b/internal/gitaly/service/operations/revert_test.go
@@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -31,10 +32,11 @@ func testServerUserRevertSuccessful(t *testing.T, ctxOuter context.Context) {
destinationBranch := "revert-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
- masterHeadCommit, err := log.GetCommit(ctxOuter, testRepo, "master")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ masterHeadCommit, err := log.GetCommit(ctxOuter, gitCmdFactory, testRepo, "master")
require.NoError(t, err)
- revertedCommit, err := log.GetCommit(ctxOuter, testRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
+ revertedCommit, err := log.GetCommit(ctxOuter, gitCmdFactory, testRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
require.NoError(t, err)
testRepoCopy, testRepoCopyPath, cleanup := testhelper.NewTestRepo(t) // read-only repo
@@ -157,7 +159,7 @@ func testServerUserRevertSuccessful(t *testing.T, ctxOuter context.Context) {
response, err := client.UserRevert(ctx, testCase.request)
require.NoError(t, err)
- headCommit, err := log.GetCommit(ctx, testCase.request.Repository, git.Revision(testCase.request.BranchName))
+ headCommit, err := log.GetCommit(ctx, gitCmdFactory, testCase.request.Repository, git.Revision(testCase.request.BranchName))
require.NoError(t, err)
expectedBranchUpdate := testCase.branchUpdate
@@ -195,7 +197,8 @@ func testServerUserRevertStableID(t *testing.T, ctxOuter context.Context) {
md := testhelper.GitalyServersMetadata(t, serverSocketPath)
ctx := testhelper.MergeOutgoingMetadata(ctxOuter, md)
- commitToRevert, err := log.GetCommit(ctxOuter, repo, "d59c60028b053793cecfb4022de34602e1a9218e")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ commitToRevert, err := log.GetCommit(ctxOuter, gitCmdFactory, repo, "d59c60028b053793cecfb4022de34602e1a9218e")
require.NoError(t, err)
response, err := client.UserRevert(ctx, &gitalypb.UserRevertRequest{
@@ -214,7 +217,7 @@ func testServerUserRevertStableID(t *testing.T, ctxOuter context.Context) {
require.Empty(t, response.CreateTreeError)
require.Empty(t, response.CreateTreeErrorCode)
- revertedCommit, err := log.GetCommit(ctx, repo, git.Revision("master"))
+ revertedCommit, err := log.GetCommit(ctx, gitCmdFactory, repo, git.Revision("master"))
require.NoError(t, err)
require.Equal(t, &gitalypb.GitCommit{
@@ -255,10 +258,11 @@ func testServerUserRevertSuccessfulIntoNewRepo(t *testing.T, ctxOuter context.Co
startRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- revertedCommit, err := log.GetCommit(ctxOuter, startRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
+ revertedCommit, err := log.GetCommit(ctxOuter, gitCmdFactory, startRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
require.NoError(t, err)
- masterHeadCommit, err := log.GetCommit(ctxOuter, startRepo, "master")
+ masterHeadCommit, err := log.GetCommit(ctxOuter, gitCmdFactory, startRepo, "master")
require.NoError(t, err)
testRepo, _, cleanup := testhelper.InitBareRepo(t)
@@ -280,7 +284,7 @@ func testServerUserRevertSuccessfulIntoNewRepo(t *testing.T, ctxOuter context.Co
response, err := client.UserRevert(ctx, request)
require.NoError(t, err)
- headCommit, err := log.GetCommit(ctx, testRepo, git.Revision(request.BranchName))
+ headCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(request.BranchName))
require.NoError(t, err)
expectedBranchUpdate := &gitalypb.OperationBranchUpdate{
@@ -313,7 +317,7 @@ func testServerUserRevertSuccessfulGitHooks(t *testing.T, ctxOuter context.Conte
destinationBranch := "revert-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
- revertedCommit, err := log.GetCommit(ctxOuter, testRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
+ revertedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
require.NoError(t, err)
request := &gitalypb.UserRevertRequest{
@@ -358,7 +362,7 @@ func testServerUserRevertFailuedDueToValidations(t *testing.T, ctxOuter context.
testRepo, _, cleanup := testhelper.NewTestRepo(t)
defer cleanup()
- revertedCommit, err := log.GetCommit(ctxOuter, testRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
+ revertedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
require.NoError(t, err)
destinationBranch := "revert-dst"
@@ -442,7 +446,7 @@ func testServerUserRevertFailedDueToPreReceiveError(t *testing.T, ctxOuter conte
destinationBranch := "revert-dst"
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
- revertedCommit, err := log.GetCommit(ctxOuter, testRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
+ revertedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, "d59c60028b053793cecfb4022de34602e1a9218e")
require.NoError(t, err)
request := &gitalypb.UserRevertRequest{
@@ -488,7 +492,7 @@ func testServerUserRevertFailedDueToCreateTreeError(t *testing.T, ctxOuter conte
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
// This revert patch of the following commit cannot be applied to the destinationBranch above
- revertedCommit, err := log.GetCommit(ctxOuter, testRepo, "372ab6950519549b14d220271ee2322caa44d4eb")
+ revertedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, "372ab6950519549b14d220271ee2322caa44d4eb")
require.NoError(t, err)
request := &gitalypb.UserRevertRequest{
@@ -527,7 +531,7 @@ func testServerUserRevertFailedDueToCommitError(t *testing.T, ctxOuter context.C
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", destinationBranch, "master")
testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "branch", sourceBranch, "a5391128b0ef5d21df5dd23d98557f4ef12fae20")
- revertedCommit, err := log.GetCommit(ctxOuter, testRepo, git.Revision(sourceBranch))
+ revertedCommit, err := log.GetCommit(ctxOuter, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(sourceBranch))
require.NoError(t, err)
request := &gitalypb.UserRevertRequest{
diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go
index f28d71fd8..c8c1f138a 100644
--- a/internal/gitaly/service/operations/squash_test.go
+++ b/internal/gitaly/service/operations/squash_test.go
@@ -13,6 +13,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -69,7 +70,7 @@ func testSuccessfulUserSquashRequest(t *testing.T, ctx context.Context, start, e
require.NoError(t, err)
require.Empty(t, response.GetGitError())
- commit, err := log.GetCommit(ctx, testRepo, git.Revision(response.SquashSha))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(response.SquashSha))
require.NoError(t, err)
require.Equal(t, []string{start}, commit.ParentIds)
require.Equal(t, author.Name, commit.Author.Name)
@@ -109,7 +110,7 @@ func TestUserSquash_stableID(t *testing.T) {
require.NoError(t, err)
require.Empty(t, response.GetGitError())
- commit, err := log.GetCommit(ctx, repo, git.Revision(response.SquashSha))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), repo, git.Revision(response.SquashSha))
require.NoError(t, err)
require.Equal(t, &gitalypb.GitCommit{
Id: "2773b7aee7d81ea96d2f48aa080cae08eaae26d5",
@@ -176,7 +177,7 @@ func TestSuccessfulUserSquashRequestWith3wayMerge(t *testing.T) {
require.NoError(t, err)
require.Empty(t, response.GetGitError())
- commit, err := log.GetCommit(ctx, testRepo, git.Revision(response.SquashSha))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(response.SquashSha))
require.NoError(t, err)
require.Equal(t, []string{"6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9"}, commit.ParentIds)
require.Equal(t, author.Name, commit.Author.Name)
@@ -283,7 +284,7 @@ func TestSquashRequestWithRenamedFiles(t *testing.T) {
require.NoError(t, err)
require.Empty(t, response.GetGitError())
- commit, err := log.GetCommit(ctx, testRepo, git.Revision(response.SquashSha))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(response.SquashSha))
require.NoError(t, err)
require.Equal(t, []string{startCommitID}, commit.ParentIds)
require.Equal(t, author.Name, commit.Author.Name)
diff --git a/internal/gitaly/service/operations/submodules_test.go b/internal/gitaly/service/operations/submodules_test.go
index 6788f85a2..de8cebd7b 100644
--- a/internal/gitaly/service/operations/submodules_test.go
+++ b/internal/gitaly/service/operations/submodules_test.go
@@ -94,7 +94,7 @@ func testSuccessfulUserUpdateSubmoduleRequest(t *testing.T, ctx context.Context)
require.Empty(t, response.GetCommitError())
require.Empty(t, response.GetPreReceiveError())
- commit, err := log.GetCommit(ctx, testRepoProto, git.Revision(response.BranchUpdate.CommitId))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepoProto, git.Revision(response.BranchUpdate.CommitId))
require.NoError(t, err)
require.Equal(t, commit.Author.Email, testhelper.TestUser.Email)
require.Equal(t, commit.Committer.Email, testhelper.TestUser.Email)
@@ -139,7 +139,7 @@ func testUserUpdateSubmoduleStableID(t *testing.T, ctx context.Context) {
require.Empty(t, response.GetCommitError())
require.Empty(t, response.GetPreReceiveError())
- commit, err := log.GetCommit(ctx, repo, git.Revision(response.BranchUpdate.CommitId))
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), repo, git.Revision(response.BranchUpdate.CommitId))
require.NoError(t, err)
require.Equal(t, &gitalypb.GitCommit{
Id: "e7752dfc2105bc830f8fa59b19dd4f3e49c8c44e",
diff --git a/internal/gitaly/service/operations/tags.go b/internal/gitaly/service/operations/tags.go
index f6311921b..572e14212 100644
--- a/internal/gitaly/service/operations/tags.go
+++ b/internal/gitaly/service/operations/tags.go
@@ -93,7 +93,7 @@ func (s *Server) UserCreateTag(ctx context.Context, req *gitalypb.UserCreateTagR
// Setup
repo := req.GetRepository()
- catFile, err := catfile.New(ctx, repo)
+ catFile, err := catfile.New(ctx, s.gitCmdFactory, repo)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go
index 71687fad9..9cb38b03d 100644
--- a/internal/gitaly/service/operations/tags_test.go
+++ b/internal/gitaly/service/operations/tags_test.go
@@ -187,7 +187,7 @@ func testSuccessfulUserCreateTagRequest(t *testing.T, ctx context.Context) {
defer cleanupFn()
targetRevision := "c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"
- targetRevisionCommit, err := log.GetCommit(ctx, testRepo, git.Revision(targetRevision))
+ targetRevisionCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(targetRevision))
require.NoError(t, err)
inputTagName := "to-be-créated-soon"
@@ -369,7 +369,7 @@ func TestUserCreateTagWithTransaction(t *testing.T) {
tagName := fmt.Sprintf("tag-%d", i)
targetRevision := "c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"
- targetCommit, err := log.GetCommit(ctx, testRepo, git.Revision(targetRevision))
+ targetCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(targetRevision))
require.NoError(t, err)
request := &gitalypb.UserCreateTagRequest{
@@ -822,7 +822,7 @@ func TestSuccessfulUserCreateTagNestedTags(t *testing.T) {
// Fake it up for all levels, except for ^{} == "commit"
responseOk.Tag.TargetCommit = response.Tag.TargetCommit
if testCase.targetObjectType == "commit" {
- responseOk.Tag.TargetCommit, err = log.GetCommit(ctx, testRepo, git.Revision(testCase.targetObject))
+ responseOk.Tag.TargetCommit, err = log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(testCase.targetObject))
require.NoError(t, err)
}
require.Equal(t, responseOk, response)
@@ -1000,7 +1000,7 @@ func TestUserCreateTagsuccessfulCreationOfPrefixedTag(t *testing.T) {
response, err := client.UserCreateTag(ctx, request)
require.Equal(t, testCase.err, err)
- commitOk, err := log.GetCommit(ctx, testRepo, git.Revision(testCase.tagTargetRevisionInput))
+ commitOk, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(testCase.tagTargetRevisionInput))
require.NoError(t, err)
responseOk := &gitalypb.UserCreateTagResponse{
diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go
index 20a2d9921..14229a9b9 100644
--- a/internal/gitaly/service/operations/testhelper_test.go
+++ b/internal/gitaly/service/operations/testhelper_test.go
@@ -91,8 +91,8 @@ func runOperationServiceServerWithRubyServer(t *testing.T, ruby *rubyserver.Serv
gitalypb.RegisterOperationServiceServer(srv.GrpcServer(), server)
gitalypb.RegisterHookServiceServer(srv.GrpcServer(), hook.NewServer(config.Config, hookManager))
gitalypb.RegisterRepositoryServiceServer(srv.GrpcServer(), repository.NewServer(config.Config, ruby, locator, txManager, gitCmdFactory))
- gitalypb.RegisterRefServiceServer(srv.GrpcServer(), ref.NewServer(config.Config, locator))
- gitalypb.RegisterCommitServiceServer(srv.GrpcServer(), commit.NewServer(config.Config, locator))
+ gitalypb.RegisterRefServiceServer(srv.GrpcServer(), ref.NewServer(config.Config, locator, gitCmdFactory))
+ gitalypb.RegisterCommitServiceServer(srv.GrpcServer(), commit.NewServer(config.Config, locator, gitCmdFactory))
gitalypb.RegisterSSHServiceServer(srv.GrpcServer(), ssh.NewServer(config.Config, locator, gitCmdFactory))
reflection.Register(srv.GrpcServer())
diff --git a/internal/gitaly/service/operations/update_branches_test.go b/internal/gitaly/service/operations/update_branches_test.go
index 5efd26691..299739bce 100644
--- a/internal/gitaly/service/operations/update_branches_test.go
+++ b/internal/gitaly/service/operations/update_branches_test.go
@@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
@@ -95,7 +96,7 @@ func testSuccessfulUserUpdateBranchRequest(t *testing.T, ctx context.Context) {
require.NoError(t, err)
require.Equal(t, responseOk, response)
- branchCommit, err := log.GetCommit(ctx, testRepo, git.Revision(testCase.updateBranchName))
+ branchCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(testCase.updateBranchName))
require.NoError(t, err)
require.Equal(t, string(testCase.newRev), branchCommit.Id)
@@ -172,7 +173,7 @@ func testSuccessfulUserUpdateBranchRequestToDelete(t *testing.T, ctx context.Con
require.Nil(t, err)
require.Equal(t, responseOk, response)
- _, err = log.GetCommit(ctx, testRepo, git.Revision(testCase.updateBranchName))
+ _, err = log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(testCase.updateBranchName))
require.True(t, log.IsNotFound(err), "expected 'not found' error got %v", err)
refs := testhelper.MustRunCommand(t, nil, "git", "-C", testRepoPath, "for-each-ref", "--", "refs/heads/"+testCase.updateBranchName)
@@ -399,7 +400,7 @@ func testFailedUserUpdateBranchRequest(t *testing.T, ctx context.Context) {
require.Equal(t, testCase.response, response)
require.Equal(t, testCase.err, err)
- branchCommit, err := log.GetCommit(ctx, testRepo, git.Revision(testCase.branchName))
+ branchCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, git.Revision(testCase.branchName))
if testCase.expectNotFoundError {
require.True(t, log.IsNotFound(err), "expected 'not found' error got %v", err)
return
diff --git a/internal/gitaly/service/ref/branches.go b/internal/gitaly/service/ref/branches.go
index b6bff60c4..1d26af477 100644
--- a/internal/gitaly/service/ref/branches.go
+++ b/internal/gitaly/service/ref/branches.go
@@ -29,7 +29,7 @@ func (s *server) FindBranch(ctx context.Context, req *gitalypb.FindBranchRequest
return nil, err
}
- commit, err := log.GetCommit(ctx, repo, git.Revision(branchRef.Target))
+ commit, err := log.GetCommit(ctx, s.gitCmdFactory, repo, git.Revision(branchRef.Target))
if err != nil {
return nil, err
}
diff --git a/internal/gitaly/service/ref/branches_test.go b/internal/gitaly/service/ref/branches_test.go
index 65ea84618..7176e821d 100644
--- a/internal/gitaly/service/ref/branches_test.go
+++ b/internal/gitaly/service/ref/branches_test.go
@@ -27,7 +27,6 @@ func TestSuccessfulFindBranchRequest(t *testing.T) {
defer cleanupFn()
repo := localrepo.New(testRepoProto, config.Config)
- locator := config.NewLocator(config.Config)
branchesByName := make(map[git.ReferenceName]*gitalypb.Branch)
for branchName, revision := range map[git.ReferenceName]git.Revision{
@@ -41,7 +40,7 @@ func TestSuccessfulFindBranchRequest(t *testing.T) {
err = repo.UpdateRef(ctx, branchName, oid, "")
require.NoError(t, err)
- commit, err := log.GetCommit(ctx, locator, testRepoProto, branchName.Revision())
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepoProto, branchName.Revision())
require.NoError(t, err)
branchesByName[branchName] = &gitalypb.Branch{
diff --git a/internal/gitaly/service/ref/list_new_blobs.go b/internal/gitaly/service/ref/list_new_blobs.go
index df8fce838..ea8dda4c0 100644
--- a/internal/gitaly/service/ref/list_new_blobs.go
+++ b/internal/gitaly/service/ref/list_new_blobs.go
@@ -38,7 +38,7 @@ func (s *server) listNewBlobs(in *gitalypb.ListNewBlobsRequest, stream gitalypb.
return err
}
- batch, err := catfile.New(ctx, in.GetRepository())
+ batch, err := catfile.New(ctx, s.gitCmdFactory, in.GetRepository())
if err != nil {
return err
}
diff --git a/internal/gitaly/service/ref/list_new_commits.go b/internal/gitaly/service/ref/list_new_commits.go
index f7d6cd7ac..d84e586f4 100644
--- a/internal/gitaly/service/ref/list_new_commits.go
+++ b/internal/gitaly/service/ref/list_new_commits.go
@@ -35,7 +35,7 @@ func (s *server) listNewCommits(in *gitalypb.ListNewCommitsRequest, stream gital
return err
}
- batch, err := catfile.New(ctx, in.GetRepository())
+ batch, err := catfile.New(ctx, s.gitCmdFactory, in.GetRepository())
if err != nil {
return err
}
diff --git a/internal/gitaly/service/ref/refs.go b/internal/gitaly/service/ref/refs.go
index 09ae6a37f..2d580dd03 100644
--- a/internal/gitaly/service/ref/refs.go
+++ b/internal/gitaly/service/ref/refs.go
@@ -99,7 +99,7 @@ func (s *server) parseAndReturnTags(ctx context.Context, repo *gitalypb.Reposito
return fmt.Errorf("for-each-ref error: %v", err)
}
- c, err := catfile.New(ctx, repo)
+ c, err := catfile.New(ctx, s.gitCmdFactory, repo)
if err != nil {
return fmt.Errorf("error creating catfile: %v", err)
}
@@ -300,7 +300,7 @@ func (s *server) FindLocalBranches(in *gitalypb.FindLocalBranchesRequest, stream
func (s *server) findLocalBranches(in *gitalypb.FindLocalBranchesRequest, stream gitalypb.RefService_FindLocalBranchesServer) error {
ctx := stream.Context()
- c, err := catfile.New(ctx, in.Repository)
+ c, err := catfile.New(ctx, s.gitCmdFactory, in.Repository)
if err != nil {
return err
}
@@ -350,7 +350,7 @@ func (s *server) findAllBranches(in *gitalypb.FindAllBranchesRequest, stream git
}
ctx := stream.Context()
- c, err := catfile.New(ctx, in.Repository)
+ c, err := catfile.New(ctx, s.gitCmdFactory, in.Repository)
if err != nil {
return err
}
@@ -427,7 +427,7 @@ func (s *server) findTag(ctx context.Context, repository *gitalypb.Repository, t
return nil, fmt.Errorf("for-each-ref error: %v", err)
}
- c, err := catfile.New(ctx, repository)
+ c, err := catfile.New(ctx, s.gitCmdFactory, repository)
if err != nil {
return nil, err
}
diff --git a/internal/gitaly/service/ref/refs_test.go b/internal/gitaly/service/ref/refs_test.go
index f91968ca7..7dccb28a5 100644
--- a/internal/gitaly/service/ref/refs_test.go
+++ b/internal/gitaly/service/ref/refs_test.go
@@ -499,7 +499,7 @@ func TestSuccessfulFindAllTagsRequest(t *testing.T) {
Message: "An empty commit with REALLY BIG message\n\n" + strings.Repeat("a", helper.MaxCommitOrTagMessageSize+1),
ParentID: "60ecb67744cb56576c30214ff52294f8ce2def98",
})
- bigCommit, err := log.GetCommit(ctx, testRepoCopy, git.Revision(bigCommitID))
+ bigCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepoCopy, git.Revision(bigCommitID))
require.NoError(t, err)
annotatedTagID := testhelper.CreateTag(t, testRepoCopyPath, "v1.2.0", blobID, &testhelper.CreateTagOpts{Message: "Blob tag"})
@@ -717,7 +717,7 @@ func TestFindAllTagNestedTags(t *testing.T) {
tags := bytes.NewReader(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoCopyPath, "tag"))
testhelper.MustRunCommand(t, tags, "xargs", config.Config.Git.BinPath, "-C", testRepoCopyPath, "tag", "-d")
- batch, err := catfile.New(ctx, testRepoCopy)
+ batch, err := catfile.New(ctx, git.NewExecCommandFactory(config.Config), testRepoCopy)
require.NoError(t, err)
info, err := batch.Info(ctx, git.Revision(tc.originalOid))
@@ -1144,7 +1144,7 @@ func TestSuccessfulFindAllBranchesRequestWithMergedBranches(t *testing.T) {
expectedBranches = append(expectedBranches, branch)
}
- masterCommit, err := log.GetCommit(ctx, testRepo, "master")
+ masterCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepo, "master")
require.NoError(t, err)
expectedBranches = append(expectedBranches, &gitalypb.FindAllBranchesResponse_Branch{
Name: []byte("refs/heads/master"),
@@ -1449,7 +1449,7 @@ func TestSuccessfulFindTagRequest(t *testing.T) {
Message: "An empty commit with REALLY BIG message\n\n" + strings.Repeat("a", helper.MaxCommitOrTagMessageSize+1),
ParentID: "60ecb67744cb56576c30214ff52294f8ce2def98",
})
- bigCommit, err := log.GetCommit(ctx, testRepoCopy, git.Revision(bigCommitID))
+ bigCommit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), testRepoCopy, git.Revision(bigCommitID))
require.NoError(t, err)
annotatedTagID := testhelper.CreateTag(t, testRepoCopyPath, "v1.2.0", blobID, &testhelper.CreateTagOpts{Message: "Blob tag"})
@@ -1648,7 +1648,7 @@ func TestFindTagNestedTag(t *testing.T) {
tags := bytes.NewReader(testhelper.MustRunCommand(t, nil, "git", "-C", testRepoCopyPath, "tag"))
testhelper.MustRunCommand(t, tags, "xargs", config.Config.Git.BinPath, "-C", testRepoCopyPath, "tag", "-d")
- batch, err := catfile.New(ctx, testRepoCopy)
+ batch, err := catfile.New(ctx, git.NewExecCommandFactory(config.Config), testRepoCopy)
require.NoError(t, err)
info, err := batch.Info(ctx, git.Revision(tc.originalOid))
diff --git a/internal/gitaly/service/ref/remote_branches.go b/internal/gitaly/service/ref/remote_branches.go
index d12dd0314..01776f221 100644
--- a/internal/gitaly/service/ref/remote_branches.go
+++ b/internal/gitaly/service/ref/remote_branches.go
@@ -30,7 +30,7 @@ func (s *server) findAllRemoteBranches(req *gitalypb.FindAllRemoteBranchesReques
patterns := []string{"refs/remotes/" + req.GetRemoteName()}
ctx := stream.Context()
- c, err := catfile.New(ctx, req.GetRepository())
+ c, err := catfile.New(ctx, s.gitCmdFactory, req.GetRepository())
if err != nil {
return err
}
diff --git a/internal/gitaly/service/ref/remote_branches_test.go b/internal/gitaly/service/ref/remote_branches_test.go
index 469058466..88ed92469 100644
--- a/internal/gitaly/service/ref/remote_branches_test.go
+++ b/internal/gitaly/service/ref/remote_branches_test.go
@@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/git/log"
+ "gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"google.golang.org/grpc/codes"
@@ -53,8 +54,9 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) {
branches := readFindAllRemoteBranchesResponsesFromClient(t, c)
require.Len(t, branches, len(expectedBranches))
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
for branchName, commitID := range expectedBranches {
- targetCommit, err := log.GetCommit(ctx, testRepo, git.Revision(commitID))
+ targetCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(commitID))
require.NoError(t, err)
expectedBranch := &gitalypb.Branch{
@@ -66,7 +68,7 @@ func TestSuccessfulFindAllRemoteBranchesRequest(t *testing.T) {
}
for branchName, commitID := range excludedBranches {
- targetCommit, err := log.GetCommit(ctx, testRepo, git.Revision(commitID))
+ targetCommit, err := log.GetCommit(ctx, gitCmdFactory, testRepo, git.Revision(commitID))
require.NoError(t, err)
excludedBranch := &gitalypb.Branch{
diff --git a/internal/gitaly/service/ref/server.go b/internal/gitaly/service/ref/server.go
index af15f66eb..610e98e0f 100644
--- a/internal/gitaly/service/ref/server.go
+++ b/internal/gitaly/service/ref/server.go
@@ -1,17 +1,19 @@
package ref
import (
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/storage"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
type server struct {
- cfg config.Cfg
- locator storage.Locator
+ cfg config.Cfg
+ locator storage.Locator
+ gitCmdFactory git.CommandFactory
}
// NewServer creates a new instance of a grpc RefServer
-func NewServer(cfg config.Cfg, locator storage.Locator) gitalypb.RefServiceServer {
- return &server{cfg: cfg, locator: locator}
+func NewServer(cfg config.Cfg, locator storage.Locator, gitCmdFactory git.CommandFactory) gitalypb.RefServiceServer {
+ return &server{cfg: cfg, locator: locator, gitCmdFactory: gitCmdFactory}
}
diff --git a/internal/gitaly/service/ref/tag_messages.go b/internal/gitaly/service/ref/tag_messages.go
index f8d081291..b5c536926 100644
--- a/internal/gitaly/service/ref/tag_messages.go
+++ b/internal/gitaly/service/ref/tag_messages.go
@@ -37,7 +37,7 @@ func validateGetTagMessagesRequest(request *gitalypb.GetTagMessagesRequest) erro
func (s *server) getAndStreamTagMessages(request *gitalypb.GetTagMessagesRequest, stream gitalypb.RefService_GetTagMessagesServer) error {
ctx := stream.Context()
- c, err := catfile.New(ctx, request.GetRepository())
+ c, err := catfile.New(ctx, s.gitCmdFactory, request.GetRepository())
if err != nil {
return err
}
diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go
index 4399ca116..b402dffe4 100644
--- a/internal/gitaly/service/ref/testhelper_test.go
+++ b/internal/gitaly/service/ref/testhelper_test.go
@@ -5,6 +5,7 @@ import (
"os"
"testing"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/hook"
hookservice "gitlab.com/gitlab-org/gitaly/internal/gitaly/service/hook"
@@ -48,7 +49,7 @@ func runRefServiceServer(t *testing.T) (func(), string) {
hookManager := hook.NewManager(locator, txManager, hook.GitlabAPIStub, config.Config)
srv := testhelper.NewServer(t, nil, nil, testhelper.WithInternalSocket(config.Config))
- gitalypb.RegisterRefServiceServer(srv.GrpcServer(), NewServer(config.Config, locator))
+ gitalypb.RegisterRefServiceServer(srv.GrpcServer(), NewServer(config.Config, locator, git.NewExecCommandFactory(config.Config)))
gitalypb.RegisterHookServiceServer(srv.GrpcServer(), hookservice.NewServer(config.Config, hookManager))
srv.Start(t)
diff --git a/internal/gitaly/service/register.go b/internal/gitaly/service/register.go
index 69daa0ff8..816cb48f4 100644
--- a/internal/gitaly/service/register.go
+++ b/internal/gitaly/service/register.go
@@ -67,13 +67,13 @@ func RegisterAll(
conns *client.Pool,
gitCmdFactory git.CommandFactory,
) {
- gitalypb.RegisterBlobServiceServer(grpcServer, blob.NewServer(rubyServer, locator))
- gitalypb.RegisterCleanupServiceServer(grpcServer, cleanup.NewServer(cfg))
- gitalypb.RegisterCommitServiceServer(grpcServer, commit.NewServer(cfg, locator))
+ gitalypb.RegisterBlobServiceServer(grpcServer, blob.NewServer(rubyServer, locator, gitCmdFactory))
+ gitalypb.RegisterCleanupServiceServer(grpcServer, cleanup.NewServer(cfg, gitCmdFactory))
+ gitalypb.RegisterCommitServiceServer(grpcServer, commit.NewServer(cfg, locator, gitCmdFactory))
gitalypb.RegisterDiffServiceServer(grpcServer, diff.NewServer(locator))
gitalypb.RegisterNamespaceServiceServer(grpcServer, namespace.NewServer(locator))
gitalypb.RegisterOperationServiceServer(grpcServer, operations.NewServer(cfg, rubyServer, hookManager, locator, conns, git.NewExecCommandFactory(cfg)))
- gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer(cfg, locator))
+ gitalypb.RegisterRefServiceServer(grpcServer, ref.NewServer(cfg, locator, gitCmdFactory))
gitalypb.RegisterRepositoryServiceServer(grpcServer, repository.NewServer(cfg, rubyServer, locator, txManager, gitCmdFactory))
gitalypb.RegisterSSHServiceServer(grpcServer, ssh.NewServer(
cfg,
diff --git a/internal/gitaly/service/remote/fetch_internal_remote_test.go b/internal/gitaly/service/remote/fetch_internal_remote_test.go
index 5a04367a7..60eac3cee 100644
--- a/internal/gitaly/service/remote/fetch_internal_remote_test.go
+++ b/internal/gitaly/service/remote/fetch_internal_remote_test.go
@@ -51,7 +51,7 @@ func TestSuccessfulFetchInternalRemote(t *testing.T) {
gitCmdFactory := git.NewExecCommandFactory(config.Config)
gitaly0Server := testhelper.NewServer(t, nil, nil, testhelper.WithStorages([]string{"gitaly-0"}))
gitalypb.RegisterSSHServiceServer(gitaly0Server.GrpcServer(), ssh.NewServer(config.Config, locator, gitCmdFactory))
- gitalypb.RegisterRefServiceServer(gitaly0Server.GrpcServer(), ref.NewServer(config.Config, locator))
+ gitalypb.RegisterRefServiceServer(gitaly0Server.GrpcServer(), ref.NewServer(config.Config, locator, gitCmdFactory))
reflection.Register(gitaly0Server.GrpcServer())
gitaly0Server.Start(t)
defer gitaly0Server.Stop()
diff --git a/internal/gitaly/service/repository/apply_gitattributes.go b/internal/gitaly/service/repository/apply_gitattributes.go
index db069353f..6c4335f84 100644
--- a/internal/gitaly/service/repository/apply_gitattributes.go
+++ b/internal/gitaly/service/repository/apply_gitattributes.go
@@ -135,7 +135,7 @@ func (s *server) ApplyGitattributes(ctx context.Context, in *gitalypb.ApplyGitat
return nil, status.Errorf(codes.InvalidArgument, "ApplyGitAttributes: revision: %v", err)
}
- c, err := catfile.New(ctx, repo)
+ c, err := catfile.New(ctx, s.gitCmdFactory, repo)
if err != nil {
return nil, err
}
diff --git a/internal/gitaly/service/repository/archive.go b/internal/gitaly/service/repository/archive.go
index 7ff1b1fda..28a2f4b89 100644
--- a/internal/gitaly/service/repository/archive.go
+++ b/internal/gitaly/service/repository/archive.go
@@ -135,7 +135,7 @@ func validateGetArchiveRequest(in *gitalypb.GetArchiveRequest, format string, pa
}
func (s *server) validateGetArchivePrecondition(ctx context.Context, in *gitalypb.GetArchiveRequest, path string, exclude []string) error {
- c, err := catfile.New(ctx, in.GetRepository())
+ c, err := catfile.New(ctx, s.gitCmdFactory, in.GetRepository())
if err != nil {
return err
}
diff --git a/internal/gitaly/service/repository/create_from_bundle_test.go b/internal/gitaly/service/repository/create_from_bundle_test.go
index bd35dd42e..fba2c2909 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/log"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/tempdir"
@@ -81,7 +82,7 @@ func TestServer_CreateRepositoryFromBundle_successful(t *testing.T) {
require.NoError(t, err)
require.NotEqual(t, 0, info.Mode()&os.ModeSymlink)
- commit, err := log.GetCommit(ctx, importedRepo, "refs/custom-refs/ref1")
+ commit, err := log.GetCommit(ctx, git.NewExecCommandFactory(config.Config), importedRepo, "refs/custom-refs/ref1")
require.NoError(t, err)
require.NotNil(t, commit)
}
diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go
index 945578bf2..337311d57 100644
--- a/internal/gitaly/service/repository/fetch_test.go
+++ b/internal/gitaly/service/repository/fetch_test.go
@@ -59,7 +59,7 @@ func TestFetchSourceBranchSourceRepositorySuccess(t *testing.T) {
require.NoError(t, err)
require.True(t, resp.Result, "response.Result should be true")
- fetchedCommit, err := gitLog.GetCommit(ctx, targetRepo, git.Revision(targetRef))
+ fetchedCommit, err := gitLog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), targetRepo, git.Revision(targetRef))
require.NoError(t, err)
require.Equal(t, newCommitID, fetchedCommit.GetId())
}
@@ -97,7 +97,7 @@ func TestFetchSourceBranchSameRepositorySuccess(t *testing.T) {
require.NoError(t, err)
require.True(t, resp.Result, "response.Result should be true")
- fetchedCommit, err := gitLog.GetCommit(ctx, repo, git.Revision(targetRef))
+ fetchedCommit, err := gitLog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), repo, git.Revision(targetRef))
require.NoError(t, err)
require.Equal(t, newCommitID, fetchedCommit.GetId())
}
diff --git a/internal/gitaly/service/repository/gc.go b/internal/gitaly/service/repository/gc.go
index 2434990a4..e97e316d9 100644
--- a/internal/gitaly/service/repository/gc.go
+++ b/internal/gitaly/service/repository/gc.go
@@ -120,7 +120,7 @@ func (s *server) cleanupKeepArounds(ctx context.Context, repo *gitalypb.Reposito
return nil
}
- batch, err := catfile.New(ctx, repo)
+ batch, err := catfile.New(ctx, s.gitCmdFactory, repo)
if err != nil {
return nil
}
diff --git a/internal/gitaly/service/repository/raw_changes.go b/internal/gitaly/service/repository/raw_changes.go
index 471a66e6e..9db19100c 100644
--- a/internal/gitaly/service/repository/raw_changes.go
+++ b/internal/gitaly/service/repository/raw_changes.go
@@ -21,7 +21,7 @@ func (s *server) GetRawChanges(req *gitalypb.GetRawChangesRequest, stream gitaly
ctx := stream.Context()
repo := req.Repository
- batch, err := catfile.New(stream.Context(), repo)
+ batch, err := catfile.New(stream.Context(), s.gitCmdFactory, repo)
if err != nil {
return helper.ErrInternal(err)
}
diff --git a/internal/gitaly/service/repository/snapshot_test.go b/internal/gitaly/service/repository/snapshot_test.go
index 798cc85f1..6425292d0 100644
--- a/internal/gitaly/service/repository/snapshot_test.go
+++ b/internal/gitaly/service/repository/snapshot_test.go
@@ -136,9 +136,10 @@ func TestGetSnapshotWithDedupe(t *testing.T) {
originalAlternatesCommit := string(commitSha)
locator := config.NewLocator(config.Config)
+ gitCmdFactory := git.NewExecCommandFactory(config.Config)
// ensure commit cannot be found in current repository
- c, err := catfile.New(ctx, testRepo)
+ c, err := catfile.New(ctx, gitCmdFactory, testRepo)
require.NoError(t, err)
_, err = c.Info(ctx, git.Revision(originalAlternatesCommit))
require.True(t, catfile.IsNotFound(err))
@@ -155,7 +156,7 @@ func TestGetSnapshotWithDedupe(t *testing.T) {
"commit", "--allow-empty", "-m", "Another empty commit")
commitSha = testhelper.CreateCommitInAlternateObjectDirectory(t, repoPath, alternateObjDir, cmd)
- c, err = catfile.New(ctx, testRepo)
+ c, err = catfile.New(ctx, gitCmdFactory, testRepo)
require.NoError(t, err)
_, err = c.Info(ctx, git.Revision(commitSha))
require.NoError(t, err)
diff --git a/internal/gitaly/service/wiki/delete_page_test.go b/internal/gitaly/service/wiki/delete_page_test.go
index dc2f21a0b..cc3bad0ed 100644
--- a/internal/gitaly/service/wiki/delete_page_test.go
+++ b/internal/gitaly/service/wiki/delete_page_test.go
@@ -74,7 +74,7 @@ func TestSuccessfulWikiDeletePageRequest(t *testing.T) {
require.NoError(t, err)
headID := testhelper.MustRunCommand(t, nil, "git", "-C", wikiRepoPath, "show", "--format=format:%H", "--no-patch", "HEAD")
- commit, err := gitlog.GetCommit(ctx, wikiRepo, git.Revision(headID))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), wikiRepo, git.Revision(headID))
require.NoError(t, err, "look up git commit after deleting a wiki page")
require.Equal(t, authorName, commit.Author.Name, "author name mismatched")
diff --git a/internal/gitaly/service/wiki/testhelper_test.go b/internal/gitaly/service/wiki/testhelper_test.go
index 6b8d72234..77943293d 100644
--- a/internal/gitaly/service/wiki/testhelper_test.go
+++ b/internal/gitaly/service/wiki/testhelper_test.go
@@ -198,7 +198,7 @@ func createTestWikiPage(t *testing.T, locator storage.Locator, client gitalypb.W
require.NoError(t, err)
writeWikiPage(t, client, wikiRepo, opts)
head1ID := testhelper.MustRunCommand(t, nil, "git", "-C", wikiRepoPath, "show", "--format=format:%H", "--no-patch", "HEAD")
- pageCommit, err := gitlog.GetCommit(ctx, wikiRepo, git.Revision(head1ID))
+ pageCommit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), wikiRepo, git.Revision(head1ID))
require.NoError(t, err, "look up git commit after writing a wiki page")
return pageCommit
diff --git a/internal/gitaly/service/wiki/update_page_test.go b/internal/gitaly/service/wiki/update_page_test.go
index 331c6683c..6381b3aa4 100644
--- a/internal/gitaly/service/wiki/update_page_test.go
+++ b/internal/gitaly/service/wiki/update_page_test.go
@@ -100,7 +100,7 @@ func TestSuccessfulWikiUpdatePageRequest(t *testing.T) {
require.NoError(t, err)
headID := testhelper.MustRunCommand(t, nil, "git", "-C", wikiRepoPath, "show", "--format=format:%H", "--no-patch", "HEAD")
- commit, err := gitlog.GetCommit(ctx, wikiRepo, git.Revision(headID))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), wikiRepo, git.Revision(headID))
require.NoError(t, err, "look up git commit before merge is applied")
require.Equal(t, authorName, commit.Author.Name, "author name mismatched")
diff --git a/internal/gitaly/service/wiki/write_page_test.go b/internal/gitaly/service/wiki/write_page_test.go
index f9c84d2e1..d62e6b8d1 100644
--- a/internal/gitaly/service/wiki/write_page_test.go
+++ b/internal/gitaly/service/wiki/write_page_test.go
@@ -103,7 +103,7 @@ func TestSuccessfulWikiWritePageRequest(t *testing.T) {
require.Empty(t, resp.DuplicateError, "DuplicateError must be empty")
headID := testhelper.MustRunCommand(t, nil, "git", "-C", wikiRepoPath, "show", "--format=format:%H", "--no-patch", "HEAD")
- commit, err := gitlog.GetCommit(ctx, wikiRepo, git.Revision(headID))
+ commit, err := gitlog.GetCommit(ctx, git.NewExecCommandFactory(config.Config), wikiRepo, git.Revision(headID))
require.NoError(t, err, "look up git commit after writing a wiki page")
require.Equal(t, authorName, commit.Author.Name, "author name mismatched")
diff --git a/internal/middleware/commandstatshandler/commandstatshandler_test.go b/internal/middleware/commandstatshandler/commandstatshandler_test.go
index fdf93e26a..3578458e4 100644
--- a/internal/middleware/commandstatshandler/commandstatshandler_test.go
+++ b/internal/middleware/commandstatshandler/commandstatshandler_test.go
@@ -11,6 +11,7 @@ import (
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/internal/gitaly/service/ref"
"gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
@@ -37,7 +38,7 @@ func createNewServer(t *testing.T) *grpc.Server {
server := grpc.NewServer(opts...)
- gitalypb.RegisterRefServiceServer(server, ref.NewServer(config.Config, config.NewLocator(config.Config)))
+ gitalypb.RegisterRefServiceServer(server, ref.NewServer(config.Config, config.NewLocator(config.Config), git.NewExecCommandFactory(config.Config)))
return server
}
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index 6a266ab4d..84591c68c 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -1020,7 +1020,7 @@ func newReplicationService(tb testing.TB) (*grpc.Server, string) {
gitalypb.RegisterObjectPoolServiceServer(svr, objectpoolservice.NewServer(gitaly_config.Config, locator, gitCmdFactory))
gitalypb.RegisterRemoteServiceServer(svr, remote.NewServer(gitaly_config.Config, RubyServer, locator, gitCmdFactory))
gitalypb.RegisterSSHServiceServer(svr, ssh.NewServer(gitaly_config.Config, locator, gitCmdFactory))
- gitalypb.RegisterRefServiceServer(svr, ref.NewServer(gitaly_config.Config, locator))
+ gitalypb.RegisterRefServiceServer(svr, ref.NewServer(gitaly_config.Config, locator, gitCmdFactory))
healthpb.RegisterHealthServer(svr, health.NewServer())
reflection.Register(svr)
diff --git a/internal/testhelper/testserver/gitaly.go b/internal/testhelper/testserver/gitaly.go
index 292b07f39..288bd47e1 100644
--- a/internal/testhelper/testserver/gitaly.go
+++ b/internal/testhelper/testserver/gitaly.go
@@ -61,7 +61,7 @@ func RealGitaly(storages []config.Storage, authToken, internalSocketPath string)
gitalyserver.NewServer(storages),
repository.NewServer(config.Config, RubyServer, locator, transactionManager, gitCmdFactory),
internalgitaly.NewServer(config.Config.Storages),
- commit.NewServer(config.Config, locator),
+ commit.NewServer(config.Config, locator, gitCmdFactory),
health.NewServer(),
}
}