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:
authorJohn Cai <johncai86@gmail.com>2022-12-27 21:35:42 +0300
committerJohn Cai <johncai86@gmail.com>2022-12-28 18:16:52 +0300
commit2cc7eb310135157178c9c486528c9f2ef851dfde (patch)
tree00a777b69f9b5555dcba6f0b98563233a12e4ca2
parenteab2255eeea3790fc767e7bbe36bd4baf6f1f58e (diff)
fixing service/repository tests
-rw-r--r--internal/gitaly/service/repository/archive_test.go3
-rw-r--r--internal/gitaly/service/repository/backup_custom_hooks_test.go1
-rw-r--r--internal/gitaly/service/repository/commit_graph_test.go31
-rw-r--r--internal/gitaly/service/repository/create_bundle_from_ref_list_test.go3
-rw-r--r--internal/gitaly/service/repository/create_bundle_test.go3
-rw-r--r--internal/gitaly/service/repository/create_fork_test.go11
-rw-r--r--internal/gitaly/service/repository/create_repository_from_url_test.go18
-rw-r--r--internal/gitaly/service/repository/fetch_remote_test.go25
-rw-r--r--internal/gitaly/service/repository/fetch_test.go22
-rw-r--r--internal/gitaly/service/repository/gc_test.go14
-rw-r--r--internal/gitaly/service/repository/has_local_branches_test.go6
-rw-r--r--internal/gitaly/service/repository/license_test.go68
-rw-r--r--internal/gitaly/service/repository/midx_test.go44
-rw-r--r--internal/gitaly/service/repository/optimize_test.go38
-rw-r--r--internal/gitaly/service/repository/prune_unreachable_objects_test.go45
-rw-r--r--internal/gitaly/service/repository/raw_changes_test.go35
-rw-r--r--internal/gitaly/service/repository/rename_test.go11
-rw-r--r--internal/gitaly/service/repository/repack_test.go45
-rw-r--r--internal/gitaly/service/repository/replicate_test.go48
-rw-r--r--internal/gitaly/service/repository/ruby_sidecar_test.go1
-rw-r--r--internal/gitaly/service/repository/search_files_test.go49
-rw-r--r--internal/gitaly/service/repository/size_test.go7
-rw-r--r--internal/gitaly/service/repository/snapshot_test.go29
-rw-r--r--internal/gitaly/service/repository/write_ref_test.go11
24 files changed, 296 insertions, 272 deletions
diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go
index 009b97719..9b5683a37 100644
--- a/internal/gitaly/service/repository/archive_test.go
+++ b/internal/gitaly/service/repository/archive_test.go
@@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/smudge"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitlab"
@@ -432,7 +433,7 @@ func TestGetArchive_pathInjection(t *testing.T) {
// a path and does not interpret it as an option.
outputPath := "/non/existent"
- commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithTree(git.WriteTree(t, cfg, repoPath, []git.TreeEntry{
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo), localrepo.WithTree(git.WriteTree(t, cfg, repoPath, []git.TreeEntry{
{Path: "--output=", Mode: "040000", OID: git.WriteTree(t, cfg, repoPath, []git.TreeEntry{
{Path: "non", Mode: "040000", OID: git.WriteTree(t, cfg, repoPath, []git.TreeEntry{
{Path: "existent", Mode: "040000", OID: git.WriteTree(t, cfg, repoPath, []git.TreeEntry{
diff --git a/internal/gitaly/service/repository/backup_custom_hooks_test.go b/internal/gitaly/service/repository/backup_custom_hooks_test.go
index ab227e7a9..3e9b99be2 100644
--- a/internal/gitaly/service/repository/backup_custom_hooks_test.go
+++ b/internal/gitaly/service/repository/backup_custom_hooks_test.go
@@ -12,6 +12,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/v15/streamio"
diff --git a/internal/gitaly/service/repository/commit_graph_test.go b/internal/gitaly/service/repository/commit_graph_test.go
index 5cb0b14eb..9a585dd4a 100644
--- a/internal/gitaly/service/repository/commit_graph_test.go
+++ b/internal/gitaly/service/repository/commit_graph_test.go
@@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
@@ -30,13 +31,9 @@ func TestWriteCommitGraph_withExistingCommitGraphCreatedWithDefaults(t *testing.
})
treeEntry := git.TreeEntry{Mode: "100644", Path: "file.txt", Content: "something"}
- WriteTestCommit(
- t, git,
-
- cfg,
- repoPath,
- git.WithBranch(t.Name()),
- git.WithTreeEntries(treeEntry))
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo),
+ localrepo.WithBranch(t.Name()),
+ localrepo.WithTreeEntries(treeEntry))
//nolint:staticcheck
res, err := client.WriteCommitGraph(ctx, &gitalypb.WriteCommitGraphRequest{
@@ -68,13 +65,9 @@ func TestWriteCommitGraph_withExistingCommitGraphCreatedWithSplit(t *testing.T)
})
treeEntry := git.TreeEntry{Mode: "100644", Path: "file.txt", Content: "something"}
- WriteTestCommit(
- t, git,
-
- cfg,
- repoPath,
- git.WithBranch(t.Name()),
- git.WithTreeEntries(treeEntry))
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo),
+ localrepo.WithBranch(t.Name()),
+ localrepo.WithTreeEntries(treeEntry))
//nolint:staticcheck
res, err := client.WriteCommitGraph(ctx, &gitalypb.WriteCommitGraphRequest{
@@ -187,13 +180,9 @@ func TestUpdateCommitGraph(t *testing.T) {
})
treeEntry := git.TreeEntry{Mode: "100644", Path: "file.txt", Content: "something"}
- WriteTestCommit(
- t, git,
-
- cfg,
- repoPath,
- git.WithBranch(t.Name()),
- git.WithTreeEntries(treeEntry))
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo),
+ localrepo.WithBranch(t.Name()),
+ localrepo.WithTreeEntries(treeEntry))
//nolint:staticcheck
res, err = client.WriteCommitGraph(ctx, &gitalypb.WriteCommitGraphRequest{
diff --git a/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go b/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go
index f283bf65b..911431c11 100644
--- a/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go
+++ b/internal/gitaly/service/repository/create_bundle_from_ref_list_test.go
@@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
@@ -28,7 +29,7 @@ func TestCreateBundleFromRefList_success(t *testing.T) {
// Create a work tree with a HEAD pointing to a commit that is missing. CreateBundle should
// clean this up before creating the bundle.
- sha := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("branch"))
+ sha := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo), localrepo.WithBranch("branch"))
require.NoError(t, os.MkdirAll(filepath.Join(repoPath, "gitlab-worktree"), 0o755))
diff --git a/internal/gitaly/service/repository/create_bundle_test.go b/internal/gitaly/service/repository/create_bundle_test.go
index ac8882e3f..63001aae1 100644
--- a/internal/gitaly/service/repository/create_bundle_test.go
+++ b/internal/gitaly/service/repository/create_bundle_test.go
@@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/tempdir"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
@@ -28,7 +29,7 @@ func TestSuccessfulCreateBundleRequest(t *testing.T) {
// Create a work tree with a HEAD pointing to a commit that is missing. CreateBundle should
// clean this up before creating the bundle.
- sha := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("branch"))
+ sha := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo), localrepo.WithBranch("branch"))
require.NoError(t, os.MkdirAll(filepath.Join(repoPath, "gitlab-worktree"), 0o755))
diff --git a/internal/gitaly/service/repository/create_fork_test.go b/internal/gitaly/service/repository/create_fork_test.go
index ed291f3b5..a7abb5535 100644
--- a/internal/gitaly/service/repository/create_fork_test.go
+++ b/internal/gitaly/service/repository/create_fork_test.go
@@ -16,6 +16,7 @@ import (
gitalyauth "gitlab.com/gitlab-org/gitaly/v15/auth"
"gitlab.com/gitlab-org/gitaly/v15/client"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/praefectutil"
@@ -121,7 +122,7 @@ func TestCreateFork_refs(t *testing.T) {
// Prepare the source repository with a bunch of refs and a non-default HEAD ref so we can
// assert that the target repo gets created with the correct set of refs.
- commitID := WriteTestCommit(t, git, cfg, sourceRepoPath)
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepo))
for _, ref := range []string{
"refs/environments/something",
"refs/heads/something",
@@ -186,10 +187,10 @@ func TestCreateFork_fsck(t *testing.T) {
{Content: "content", Path: "dup", Mode: "100644"},
})
- git.WriteTestCommit(t, cfg, repoPath,
- git.WithParents(),
- git.WithBranch("main"),
- git.WithTree(treeID),
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo),
+ localrepo.WithParents(),
+ localrepo.WithBranch("main"),
+ localrepo.WithTree(treeID),
)
forkedRepo := &gitalypb.Repository{
diff --git a/internal/gitaly/service/repository/create_repository_from_url_test.go b/internal/gitaly/service/repository/create_repository_from_url_test.go
index 2c5fdf39e..b3008e9e6 100644
--- a/internal/gitaly/service/repository/create_repository_from_url_test.go
+++ b/internal/gitaly/service/repository/create_repository_from_url_test.go
@@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v15/internal/praefect/praefectutil"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
@@ -67,9 +68,10 @@ func TestCreateRepositoryFromURL_successfulWithOptionalParameters(t *testing.T)
cfg, client := setupRepositoryServiceWithoutRepo(t)
gitCmdFactory := git.NewCommandFactory(t, cfg)
- _, remoteRepoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, remoteRepoPath, git.WithBranch(git.DefaultBranch))
- WriteTestCommit(t, git, cfg, remoteRepoPath, git.WithReference("refs/merge-requests/1/head"))
+ remoteRepoProto, remoteRepoPath := git.CreateRepository(t, ctx, cfg)
+ remoteRepo := localrepo.NewTestRepo(t, cfg, remoteRepoProto)
+ localrepo.WriteTestCommit(t, remoteRepo, localrepo.WithBranch(git.DefaultBranch))
+ localrepo.WriteTestCommit(t, remoteRepo, localrepo.WithReference("refs/merge-requests/1/head"))
user := "username123"
password := "password321localhost"
@@ -182,14 +184,14 @@ func TestCreateRepositoryFromURL_fsck(t *testing.T) {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- _, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
// We're creating a new commit which has a root tree with duplicate entries. git-mktree(1)
// allows us to create these trees just fine, but git-fsck(1) complains.
- git.WriteTestCommit(t, cfg, sourceRepoPath,
- git.WithParents(),
- git.WithBranch("main"),
- git.WithTreeEntries(
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto),
+ localrepo.WithParents(),
+ localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(
git.TreeEntry{Content: "content", Path: "dup", Mode: "100644"},
git.TreeEntry{Content: "content", Path: "dup", Mode: "100644"},
),
diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go
index 81dfc280a..947f51be4 100644
--- a/internal/gitaly/service/repository/fetch_remote_test.go
+++ b/internal/gitaly/service/repository/fetch_remote_test.go
@@ -37,9 +37,9 @@ func TestFetchRemote_checkTagsChanged(t *testing.T) {
ctx := testhelper.Context(t)
cfg, client := setupRepositoryServiceWithoutRepo(t)
- _, remoteRepoPath := git.CreateRepository(t, ctx, cfg)
+ remoteRepoProto, remoteRepoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, remoteRepoPath, git.WithBranch("main"))
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, remoteRepoProto), localrepo.WithBranch("main"))
t.Run("check tags without tags", func(t *testing.T) {
repoProto, _ := git.CreateRepository(t, ctx, cfg)
@@ -342,8 +342,8 @@ func TestFetchRemote_force(t *testing.T) {
tagOID, err := sourceRepo.ResolveRevision(ctx, "refs/tags/v1.0.0")
require.NoError(t, err)
- divergingBranchOID := WriteTestCommit(t, git, cfg, sourceRepoPath, git.WithBranch("b1"))
- divergingTagOID := WriteTestCommit(t, git, cfg, sourceRepoPath, git.WithBranch("b2"))
+ divergingBranchOID := localrepo.WriteTestCommit(t, sourceRepo, localrepo.WithBranch("b1"))
+ divergingTagOID := localrepo.WriteTestCommit(t, sourceRepo, localrepo.WithBranch("b2"))
port := git.HTTPServer(t, ctx, gitCmdFactory, sourceRepoPath, nil)
@@ -807,10 +807,11 @@ func TestFetchRemote_pooledRepository(t *testing.T) {
// single reference with an object that is neither in the pool member nor in
// the remote. If alternate refs are used, then Git will announce it to the
// remote as "have".
- _, poolRepoPath := git.CreateRepository(t, ctx, cfg)
- poolCommitID := WriteTestCommit(t, git, cfg, poolRepoPath,
- git.WithBranch("pooled"),
- git.WithTreeEntries(git.TreeEntry{Path: "pool", Mode: "100644", Content: "pool contents"}))
+ poolRepoProto, poolRepoPath := git.CreateRepository(t, ctx, cfg)
+
+ poolCommitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, poolRepoProto),
+ localrepo.WithBranch("pooled"),
+ localrepo.WithTreeEntries(git.TreeEntry{Path: "pool", Mode: "100644", Content: "pool contents"}))
// Create the pooled repository and link it to its pool. This is the
// repository we're fetching into.
@@ -820,10 +821,10 @@ func TestFetchRemote_pooledRepository(t *testing.T) {
// And then finally create a third repository that emulates the remote side
// we're fetching from. We need to create at least one reference so that Git
// would actually try to fetch objects.
- _, remoteRepoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, remoteRepoPath,
- git.WithBranch("remote"),
- git.WithTreeEntries(git.TreeEntry{Path: "remote", Mode: "100644", Content: "remote contents"}))
+ remoteRepoProto, remoteRepoPath := git.CreateRepository(t, ctx, cfg)
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, remoteRepoProto),
+ localrepo.WithBranch("remote"),
+ localrepo.WithTreeEntries(git.TreeEntry{Path: "remote", Mode: "100644", Content: "remote contents"}))
// Set up an HTTP server and intercept the request. This is done so that we
// can observe the reference negotiation and check whether alternate refs
diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go
index a24534da0..806837a95 100644
--- a/internal/gitaly/service/repository/fetch_test.go
+++ b/internal/gitaly/service/repository/fetch_test.go
@@ -40,7 +40,7 @@ func TestFetchSourceBranch(t *testing.T) {
setup: func(t *testing.T) setupData {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto), localrepo.WithBranch("master"))
repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
@@ -91,8 +91,8 @@ func TestFetchSourceBranch(t *testing.T) {
setup: func(t *testing.T) setupData {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
- git.WriteCommit(t, cfg, sourceRepoPath)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto))
repoProto, _ := git.CreateRepository(t, ctx, cfg)
return setupData{
@@ -113,8 +113,8 @@ func TestFetchSourceBranch(t *testing.T) {
setup: func(t *testing.T) setupData {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
- git.WriteCommit(t, cfg, sourceRepoPath)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto))
return setupData{
cfg: cfg,
@@ -260,7 +260,7 @@ func TestFetchSourceBranch(t *testing.T) {
setup: func(t *testing.T) setupData {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto), localrepo.WithBranch("master"))
repoProto, _ := git.CreateRepository(t, ctx, cfg)
@@ -281,7 +281,7 @@ func TestFetchSourceBranch(t *testing.T) {
setup: func(t *testing.T) setupData {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto), localrepo.WithBranch("master"))
repoProto, _ := git.CreateRepository(t, ctx, cfg)
@@ -303,7 +303,7 @@ func TestFetchSourceBranch(t *testing.T) {
setup: func(t *testing.T) setupData {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto), localrepo.WithBranch("master"))
repoProto, _ := git.CreateRepository(t, ctx, cfg)
@@ -325,7 +325,7 @@ func TestFetchSourceBranch(t *testing.T) {
setup: func(t *testing.T) setupData {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto), localrepo.WithBranch("master"))
repoProto, _ := git.CreateRepository(t, ctx, cfg)
@@ -347,7 +347,7 @@ func TestFetchSourceBranch(t *testing.T) {
setup: func(t *testing.T) setupData {
cfg, client := setupRepositoryServiceWithoutRepo(t)
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto), localrepo.WithBranch("master"))
repoProto, _ := git.CreateRepository(t, ctx, cfg)
@@ -387,7 +387,7 @@ func TestFetchSourceBranch(t *testing.T) {
client, serverSocketPath := runRepositoryService(t, cfg, nil, testserver.WithGitCommandFactory(gitCmdFactory))
cfg.SocketPath = serverSocketPath
- sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, _ := git.CreateRepository(t, ctx, cfg)
commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto), localrepo.WithBranch("master"))
repoProto, _ := git.CreateRepository(t, ctx, cfg)
diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go
index bfbb25f39..24e215825 100644
--- a/internal/gitaly/service/repository/gc_test.go
+++ b/internal/gitaly/service/repository/gc_test.go
@@ -110,8 +110,8 @@ func TestGarbageCollectWithPrune(t *testing.T) {
oldReferencedObjFile := filepath.Join(repoPath, "objects", blobHashes[2][:2], blobHashes[2][2:])
// create a reference to the blob, so it should not be removed by gc
- WriteTestCommit(t, git, cfg, repoPath,
- git.WithTreeEntries(git.TreeEntry{
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo),
+ localrepo.WithTreeEntries(git.TreeEntry{
OID: git.ObjectID(blobHashes[2]), Path: "blob-name", Mode: "100644",
}))
@@ -236,7 +236,7 @@ func TestGarbageCollectDeletesPackedRefsLock(t *testing.T) {
repo, repoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"))
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo), localrepo.WithBranch("main"))
git.Exec(t, cfg, "-C", repoPath, "pack-refs", "--all")
// Force the packed-refs file to have an old time to test that even
@@ -556,10 +556,10 @@ func TestGarbageCollectDeltaIslands(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx)
+ cfg, repo, _, client := setupRepositoryService(t, ctx)
localRepo := localrepo.NewTestRepo(t, cfg, repo)
- localrepo.TestDeltaIslands(t, cfg, repo, repo, false, func() error {
+ localrepo.TestDeltaIslands(t, cfg, localRepo, localRepo, false, func() error {
//nolint:staticcheck
_, err := client.GarbageCollect(ctx, &gitalypb.GarbageCollectRequest{Repository: repo})
return err
@@ -575,12 +575,12 @@ func TestGarbageCollect_commitGraphsWithPrunedObjects(t *testing.T) {
repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
// Write a first commit-graph that contains the root commit, only.
- rootCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"))
+ rootCommitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithBranch("main"))
git.Exec(t, cfg, "-C", repoPath, "commit-graph", "write", "--reachable", "--split", "--changed-paths")
// Write a second, incremental commit-graph that contains a commit we're about to
// make unreachable and then prune.
- unreachableCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(rootCommitID), git.WithBranch("main"))
+ unreachableCommitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithParents(rootCommitID), localrepo.WithBranch("main"))
git.Exec(t, cfg, "-C", repoPath, "commit-graph", "write", "--reachable", "--split=no-merge", "--changed-paths")
// Reset the "main" branch back to the initial root commit ID and prune the now
diff --git a/internal/gitaly/service/repository/has_local_branches_test.go b/internal/gitaly/service/repository/has_local_branches_test.go
index 3d4f32729..88dd2d75d 100644
--- a/internal/gitaly/service/repository/has_local_branches_test.go
+++ b/internal/gitaly/service/repository/has_local_branches_test.go
@@ -4,6 +4,8 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
@@ -15,8 +17,8 @@ func TestHasLocalBranches_successful(t *testing.T) {
ctx := testhelper.Context(t)
cfg, client := setupRepositoryServiceWithoutRepo(t)
- populatedRepo, populatedRepoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, populatedRepoPath, git.WithBranch("main"))
+ populatedRepo, _ := git.CreateRepository(t, ctx, cfg)
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, populatedRepo), localrepo.WithBranch("main"))
emptyRepo, _ := git.CreateRepository(t, ctx, cfg)
diff --git a/internal/gitaly/service/repository/license_test.go b/internal/gitaly/service/repository/license_test.go
index f865c0f89..2b710ed35 100644
--- a/internal/gitaly/service/repository/license_test.go
+++ b/internal/gitaly/service/repository/license_test.go
@@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/catfile"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/v15/internal/metadata/featureflag"
@@ -53,7 +54,7 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
for _, tc := range []struct {
desc string
nonExistentRepository bool
- setup func(t *testing.T, repoPath string)
+ setup func(t *testing.T, repo *localrepo.Repo)
// expectedLicenseRuby is used to verify the response received from the Ruby side-car.
// Also is it used if expectedLicenseGo is not set. Because the Licensee gem and
// the github.com/go-enry/go-license-detector go package use different license databases
@@ -65,16 +66,18 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
}{
{
desc: "repository does not exist",
- setup: func(t *testing.T, repoPath string) {
+ setup: func(t *testing.T, repo *localrepo.Repo) {
+ repoPath, err := repo.Path()
+ require.NoError(t, err)
require.NoError(t, os.RemoveAll(repoPath))
},
errorContains: "GetRepoPath: not a git repository",
},
{
desc: "empty if no license file in repo",
- setup: func(t *testing.T, repoPath string) {
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"),
- git.WithTreeEntries(
+ setup: func(t *testing.T, repo *localrepo.Repo) {
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(
git.TreeEntry{
Mode: "100644",
Path: "README.md",
@@ -86,9 +89,9 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
},
{
desc: "high confidence mit result and less confident mit-0 result",
- setup: func(t *testing.T, repoPath string) {
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"),
- git.WithTreeEntries(
+ setup: func(t *testing.T, repo *localrepo.Repo) {
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(
git.TreeEntry{
Mode: "100644",
Path: "LICENSE",
@@ -111,9 +114,9 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
},
{
desc: "unknown license",
- setup: func(t *testing.T, repoPath string) {
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"),
- git.WithTreeEntries(
+ setup: func(t *testing.T, repo *localrepo.Repo) {
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(
git.TreeEntry{
Mode: "100644",
Path: "LICENSE.md",
@@ -136,11 +139,11 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
},
{
desc: "deprecated license",
- setup: func(t *testing.T, repoPath string) {
+ setup: func(t *testing.T, repo *localrepo.Repo) {
deprecatedLicenseData := testhelper.MustReadFile(t, "testdata/gnu_license.deprecated.txt")
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"),
- git.WithTreeEntries(
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(
git.TreeEntry{
Mode: "100644",
Path: "LICENSE",
@@ -165,11 +168,11 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
},
{
desc: "license with nickname",
- setup: func(t *testing.T, repoPath string) {
+ setup: func(t *testing.T, repo *localrepo.Repo) {
licenseText := testhelper.MustReadFile(t, "testdata/gpl-2.0_license.txt")
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"),
- git.WithTreeEntries(
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(
git.TreeEntry{
Mode: "100644",
Path: "LICENSE",
@@ -194,7 +197,10 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
},
{
desc: "license in subdir",
- setup: func(t *testing.T, repoPath string) {
+ setup: func(t *testing.T, repo *localrepo.Repo) {
+ repoPath, err := repo.Path()
+ require.NoError(t, err)
+
subTree := git.WriteTree(t, cfg, repoPath,
[]git.TreeEntry{{
Mode: "100644",
@@ -202,8 +208,8 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
Content: mitLicense,
}})
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"),
- git.WithTreeEntries(
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(
git.TreeEntry{
Mode: "040000",
Path: "legal",
@@ -215,9 +221,9 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
},
{
desc: "license pointing to license file",
- setup: func(t *testing.T, repoPath string) {
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"),
- git.WithTreeEntries(
+ setup: func(t *testing.T, repo *localrepo.Repo) {
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(
git.TreeEntry{
Mode: "100644",
Path: "mit.txt",
@@ -246,14 +252,16 @@ func testSuccessfulFindLicenseRequest(t *testing.T, cfg config.Cfg, client gital
},
} {
t.Run(tc.desc, func(t *testing.T) {
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
- tc.setup(t, repoPath)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
+ repo := localrepo.NewTestRepo(t, cfg, repoProto)
+
+ tc.setup(t, repo)
if _, err := os.Stat(repoPath); !os.IsNotExist(err) {
git.Exec(t, cfg, "-C", repoPath, "symbolic-ref", "HEAD", "refs/heads/main")
}
- resp, err := client.FindLicense(ctx, &gitalypb.FindLicenseRequest{Repository: repo})
+ resp, err := client.FindLicense(ctx, &gitalypb.FindLicenseRequest{Repository: repoProto})
if tc.errorContains != "" {
require.Error(t, err)
require.Contains(t, err.Error(), tc.errorContains)
@@ -315,7 +323,7 @@ func BenchmarkFindLicense(b *testing.B) {
Seed: "benchmark.git",
})
- repoStress, repoStressPath := git.CreateRepository(b, ctx, cfg, git.CreateRepositoryConfig{
+ repoStressProto, repoStressPath := git.CreateRepository(b, ctx, cfg, git.CreateRepositoryConfig{
SkipCreationViaService: true,
})
@@ -365,8 +373,8 @@ func BenchmarkFindLicense(b *testing.B) {
}
}
- WriteTestCommit(b, git, cfg, repoStressPath, git.WithBranch("main"),
- git.WithTreeEntries(treeEntries...))
+ localrepo.WriteTestCommit(b, localrepo.NewTestRepo(b, cfg, repoStressProto), localrepo.WithBranch("main"),
+ localrepo.WithTreeEntries(treeEntries...))
git.Exec(b, cfg, "-C", repoStressPath, "symbolic-ref", "HEAD", "refs/heads/main")
@@ -387,7 +395,7 @@ func BenchmarkFindLicense(b *testing.B) {
},
{
desc: "stress.git",
- repo: repoStress,
+ repo: repoStressProto,
},
} {
b.Run(tc.desc, func(b *testing.B) {
diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go
index 6bbe84a8f..53456e32d 100644
--- a/internal/gitaly/service/repository/midx_test.go
+++ b/internal/gitaly/service/repository/midx_test.go
@@ -18,6 +18,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/backchannel"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/transaction"
@@ -36,10 +37,10 @@ func TestMidxWrite(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx)
+ cfg, repoProto, repoPath, client := setupRepositoryService(t, ctx)
//nolint:staticcheck
- _, err := client.MidxRepack(ctx, &gitalypb.MidxRepackRequest{Repository: repo})
+ _, err := client.MidxRepack(ctx, &gitalypb.MidxRepackRequest{Repository: repoProto})
assert.NoError(t, err)
require.FileExists(t,
@@ -55,7 +56,7 @@ func TestMidxRewrite(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, repo, repoPath, client := setupRepositoryService(t, ctx)
+ _, repoProto, repoPath, client := setupRepositoryService(t, ctx)
midxPath := filepath.Join(repoPath, MidxRelPath)
@@ -68,7 +69,7 @@ func TestMidxRewrite(t *testing.T) {
mt := info.ModTime()
//nolint:staticcheck
- _, err = client.MidxRepack(ctx, &gitalypb.MidxRepackRequest{Repository: repo})
+ _, err = client.MidxRepack(ctx, &gitalypb.MidxRepackRequest{Repository: repoProto})
require.NoError(t, err)
require.FileExists(t,
@@ -84,12 +85,13 @@ func TestMidxRepack(t *testing.T) {
ctx := testhelper.Context(t)
cfg, client := setupRepositoryServiceWithoutRepo(t)
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"))
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
+ repo := localrepo.NewTestRepo(t, cfg, repoProto)
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"))
// add some pack files with different sizes
packsAdded := 5
- addPackFiles(t, ctx, cfg, repoPath, packsAdded, true)
+ addPackFiles(t, ctx, cfg, repo, packsAdded, true)
// record pack count
actualCount, err := stats.PackfilesCount(repoPath)
@@ -104,7 +106,7 @@ func TestMidxRepack(t *testing.T) {
_, err = client.MidxRepack(
ctx,
&gitalypb.MidxRepackRequest{
- Repository: repo,
+ Repository: repoProto,
},
)
require.NoError(t, err)
@@ -128,8 +130,8 @@ func TestMidxRepack_transactional(t *testing.T) {
txManager := transaction.NewTrackingManager()
cfg, client := setupRepositoryServiceWithoutRepo(t, testserver.WithTransactionManager(txManager))
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(git.DefaultBranch))
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithBranch(git.DefaultBranch))
git.Exec(t, cfg, "-C", repoPath, "repack", "-Ad")
// Reset the votes after creating the test repository.
@@ -144,7 +146,7 @@ func TestMidxRepack_transactional(t *testing.T) {
//nolint:staticcheck
_, err = client.MidxRepack(ctx, &gitalypb.MidxRepackRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
@@ -163,11 +165,12 @@ func TestMidxRepackExpire(t *testing.T) {
for _, packsAdded := range []int{3, 5, 11, 20} {
t.Run(fmt.Sprintf("Test repack expire with %d added packs", packsAdded),
func(t *testing.T) {
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"))
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
+ repo := localrepo.NewTestRepo(t, cfg, repoProto)
+ localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"))
// add some pack files with different sizes
- addPackFiles(t, ctx, cfg, repoPath, packsAdded, false)
+ addPackFiles(t, ctx, cfg, repo, packsAdded, false)
// record pack count
actualCount, err := stats.PackfilesCount(repoPath)
@@ -194,7 +197,7 @@ func TestMidxRepackExpire(t *testing.T) {
_, err := client.MidxRepack(
ctx,
&gitalypb.MidxRepackRequest{
- Repository: repo,
+ Repository: repoProto,
},
)
require.NoError(t, err)
@@ -250,12 +253,15 @@ func addPackFiles(
t *testing.T,
ctx context.Context,
cfg config.Cfg,
- repoPath string,
+ repo *localrepo.Repo,
packCount int,
resetModTime bool,
) {
t.Helper()
+ repoPath, err := repo.Path()
+ require.NoError(t, err)
+
// Do a full repack to ensure we start with 1 pack.
git.Exec(t, cfg, "-C", repoPath, "repack", "-Ad")
@@ -267,9 +273,9 @@ func addPackFiles(
_, err := io.ReadFull(randomReader, buf)
require.NoError(t, err)
- WriteTestCommit(t, git, cfg, repoPath,
- git.WithMessage(hex.EncodeToString(buf)),
- git.WithBranch(fmt.Sprintf("branch-%d", i)))
+ localrepo.WriteTestCommit(t, repo,
+ localrepo.WithMessage(hex.EncodeToString(buf)),
+ localrepo.WithBranch(fmt.Sprintf("branch-%d", i)))
git.Exec(t, cfg, "-C", repoPath, "repack", "-d")
}
diff --git a/internal/gitaly/service/repository/optimize_test.go b/internal/gitaly/service/repository/optimize_test.go
index b3d69dbea..2e302171e 100644
--- a/internal/gitaly/service/repository/optimize_test.go
+++ b/internal/gitaly/service/repository/optimize_test.go
@@ -34,7 +34,7 @@ func TestOptimizeRepository(t *testing.T) {
t.Run("gitconfig credentials get pruned", func(t *testing.T) {
t.Parallel()
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
gitconfigPath := filepath.Join(repoPath, "config")
readConfig := func() []string {
@@ -72,7 +72,7 @@ func TestOptimizeRepository(t *testing.T) {
// Calling OptimizeRepository should cause us to strip any of the added creds from
// the gitconfig.
_, err := client.OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
// The gitconfig should not contain any of the stripped gitconfig values anymore.
@@ -82,13 +82,13 @@ func TestOptimizeRepository(t *testing.T) {
t.Run("up-to-date packfile does not get repacked", func(t *testing.T) {
t.Parallel()
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
// Write a commit and force-repack the whole repository. This is to ensure that the
// repository is in a state where it shouldn't need to be repacked.
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"))
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithBranch("master"))
_, err := client.OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{
- Repository: repo,
+ Repository: repoProto,
Strategy: gitalypb.OptimizeRepositoryRequest_STRATEGY_EAGER,
})
require.NoError(t, err)
@@ -101,7 +101,7 @@ func TestOptimizeRepository(t *testing.T) {
// should see that the repository was in a well-defined state already, so we should
// not perform any optimization.
_, err = client.OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
@@ -114,8 +114,8 @@ func TestOptimizeRepository(t *testing.T) {
t.Run("missing bitmap causes full repack", func(t *testing.T) {
t.Parallel()
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"))
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithBranch("master"))
bitmaps, err := filepath.Glob(filepath.Join(repoPath, "objects", "pack", "*.bitmap"))
require.NoError(t, err)
@@ -126,7 +126,7 @@ func TestOptimizeRepository(t *testing.T) {
// out a new bitmap via a full repack. This is so that all repositories will have a
// bitmap available.
_, err = client.OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
@@ -138,8 +138,8 @@ func TestOptimizeRepository(t *testing.T) {
t.Run("optimizing repository without commit-graph bloom filters", func(t *testing.T) {
t.Parallel()
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"))
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithBranch("master"))
// Prepare the repository so that it has a commit-graph, but that commit-graph is
// missing bloom filters.
@@ -154,7 +154,7 @@ func TestOptimizeRepository(t *testing.T) {
// As a result, OptimizeRepository should rewrite the commit-graph.
_, err = client.OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
@@ -171,7 +171,7 @@ func TestOptimizeRepository(t *testing.T) {
t.Run("empty ref directories get pruned after grace period", func(t *testing.T) {
t.Parallel()
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
// Git will leave behind empty refs directories at times. In order to not slow down
// enumerating refs we want to make sure that they get cleaned up properly.
@@ -182,7 +182,7 @@ func TestOptimizeRepository(t *testing.T) {
// because we have a grace period so that we don't delete empty ref directories that
// have just been created by a concurrently running Git process.
_, err := client.OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
require.DirExists(t, emptyRefsDir)
@@ -198,7 +198,7 @@ func TestOptimizeRepository(t *testing.T) {
// Now the second call to OptimizeRepository should indeed clean up the empty refs
// directories.
_, err = client.OptimizeRepository(ctx, &gitalypb.OptimizeRepositoryRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
// We shouldn't have removed the top-level "refs" directory.
@@ -285,7 +285,7 @@ func TestOptimizeRepository_validation(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, _, client := setupRepositoryService(t, ctx)
+ cfg, repoProto, _, client := setupRepositoryService(t, ctx)
for _, tc := range []struct {
desc string
@@ -305,7 +305,7 @@ func TestOptimizeRepository_validation(t *testing.T) {
request: &gitalypb.OptimizeRepositoryRequest{
Repository: &gitalypb.Repository{
StorageName: "non-existent",
- RelativePath: repo.GetRelativePath(),
+ RelativePath: repoProto.GetRelativePath(),
},
},
expectedErr: structerr.NewInvalidArgument(testhelper.GitalyOrPraefect(
@@ -317,7 +317,7 @@ func TestOptimizeRepository_validation(t *testing.T) {
desc: "invalid repository path",
request: &gitalypb.OptimizeRepositoryRequest{
Repository: &gitalypb.Repository{
- StorageName: repo.GetStorageName(),
+ StorageName: repoProto.GetStorageName(),
RelativePath: "path/not/exist",
},
},
@@ -329,7 +329,7 @@ func TestOptimizeRepository_validation(t *testing.T) {
{
desc: "invalid optimization strategy",
request: &gitalypb.OptimizeRepositoryRequest{
- Repository: repo,
+ Repository: repoProto,
Strategy: 12,
},
expectedErr: structerr.NewInvalidArgument("unsupported optimization strategy 12"),
diff --git a/internal/gitaly/service/repository/prune_unreachable_objects_test.go b/internal/gitaly/service/repository/prune_unreachable_objects_test.go
index 54d2d9c35..a036361e2 100644
--- a/internal/gitaly/service/repository/prune_unreachable_objects_test.go
+++ b/internal/gitaly/service/repository/prune_unreachable_objects_test.go
@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
@@ -36,32 +37,32 @@ func TestPruneUnreachableObjects(t *testing.T) {
})
t.Run("relative path points to removed repository", func(t *testing.T) {
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
require.NoError(t, os.RemoveAll(repoPath))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
- Repository: repo,
+ Repository: repoProto,
})
testhelper.RequireGrpcError(t, structerr.NewNotFound("GetRepoPath: not a git repository: %q", repoPath), err)
})
t.Run("empty repository", func(t *testing.T) {
- repo, _ := git.CreateRepository(t, ctx, cfg)
+ repoProto, _ := git.CreateRepository(t, ctx, cfg)
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
})
t.Run("repository with reachable objects", func(t *testing.T) {
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
// Create the commit and a branch pointing to it to make it reachable.
- commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("branch"))
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithBranch("branch"))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
@@ -70,16 +71,16 @@ func TestPruneUnreachableObjects(t *testing.T) {
})
t.Run("repository with recent unreachable objects", func(t *testing.T) {
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
// Create the commit, but don't create a reference pointing to it.
- commitID := WriteTestCommit(t, git, cfg, repoPath)
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto))
// Set the object time to something that's close to 30 minutes, but gives us enough
// room to not cause flakes.
setObjectTime(t, repoPath, commitID, time.Now().Add(-28*time.Minute))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
@@ -89,14 +90,14 @@ func TestPruneUnreachableObjects(t *testing.T) {
})
t.Run("repository with old unreachable objects", func(t *testing.T) {
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
// Create the commit, but don't create a reference pointing to it.
- commitID := WriteTestCommit(t, git, cfg, repoPath)
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto))
setObjectTime(t, repoPath, commitID, time.Now().Add(-31*time.Minute))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
@@ -107,19 +108,19 @@ func TestPruneUnreachableObjects(t *testing.T) {
})
t.Run("repository with mixed objects", func(t *testing.T) {
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
- reachableOldCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithMessage("a"), git.WithBranch("branch"))
+ reachableOldCommit := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithMessage("a"), localrepo.WithBranch("branch"))
setObjectTime(t, repoPath, reachableOldCommit, time.Now().Add(-31*time.Minute))
- unreachableRecentCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithMessage("b"))
+ unreachableRecentCommit := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithMessage("b"))
setObjectTime(t, repoPath, unreachableRecentCommit, time.Now().Add(-28*time.Minute))
- unreachableOldCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithMessage("c"))
+ unreachableOldCommit := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithMessage("c"))
setObjectTime(t, repoPath, unreachableOldCommit, time.Now().Add(-31*time.Minute))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
@@ -135,13 +136,13 @@ func TestPruneUnreachableObjects(t *testing.T) {
})
t.Run("repository with commit-graph", func(t *testing.T) {
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
// Write two commits into the repository and create a commit-graph. The second
// commit will become unreachable and will be pruned, but will be contained in the
// commit-graph.
- rootCommitID := WriteTestCommit(t, git, cfg, repoPath)
- unreachableCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(rootCommitID), git.WithBranch("main"))
+ rootCommitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto))
+ unreachableCommitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithParents(rootCommitID), localrepo.WithBranch("main"))
git.Exec(t, cfg, "-C", repoPath, "commit-graph", "write", "--reachable", "--split", "--changed-paths")
// Reset the "main" branch back to the initial root commit ID and prune the now
@@ -153,7 +154,7 @@ func TestPruneUnreachableObjects(t *testing.T) {
setObjectTime(t, repoPath, unreachableCommitID, time.Now().Add(-30*time.Minute))
_, err := client.PruneUnreachableObjects(ctx, &gitalypb.PruneUnreachableObjectsRequest{
- Repository: repo,
+ Repository: repoProto,
})
require.NoError(t, err)
diff --git a/internal/gitaly/service/repository/raw_changes_test.go b/internal/gitaly/service/repository/raw_changes_test.go
index d1b2dd822..110bee8be 100644
--- a/internal/gitaly/service/repository/raw_changes_test.go
+++ b/internal/gitaly/service/repository/raw_changes_test.go
@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/structerr"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
@@ -19,7 +20,7 @@ func TestGetRawChanges(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, repo, _, client := setupRepositoryService(t, ctx)
+ _, repoProto, _, client := setupRepositoryService(t, ctx)
testCases := []struct {
oldRev string
@@ -95,7 +96,7 @@ func TestGetRawChanges(t *testing.T) {
for _, tc := range testCases {
t.Run(fmt.Sprintf("old:%s,new:%s", tc.oldRev, tc.newRev), func(t *testing.T) {
req := &gitalypb.GetRawChangesRequest{
- Repository: repo,
+ Repository: repoProto,
FromRevision: tc.oldRev,
ToRevision: tc.newRev,
}
@@ -121,10 +122,10 @@ func TestGetRawChangesSpecialCharacters(t *testing.T) {
// characters.
ctx := testhelper.Context(t)
- _, repo, _, client := setupRepositoryService(t, ctx)
+ _, repoProto, _, client := setupRepositoryService(t, ctx)
req := &gitalypb.GetRawChangesRequest{
- Repository: repo,
+ Repository: repoProto,
FromRevision: "cfe32cf61b73a0d5e9f13e774abde7ff789b1660",
ToRevision: "913c66a37b4a45b9769037c55c2d238bd0942d2e",
}
@@ -161,7 +162,7 @@ func TestGetRawChangesFailures(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, repo, _, client := setupRepositoryService(t, ctx)
+ _, repoProto, _, client := setupRepositoryService(t, ctx)
for _, tc := range []struct {
desc string
@@ -171,7 +172,7 @@ func TestGetRawChangesFailures(t *testing.T) {
{
desc: "missing from-revision",
request: &gitalypb.GetRawChangesRequest{
- Repository: repo,
+ Repository: repoProto,
FromRevision: "",
ToRevision: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863",
},
@@ -191,7 +192,7 @@ func TestGetRawChangesFailures(t *testing.T) {
{
desc: "missing commit",
request: &gitalypb.GetRawChangesRequest{
- Repository: repo,
+ Repository: repoProto,
// A Gitaly commit, unresolvable in gitlab-test
FromRevision: "32800ed8206c0087f65e90a1a396b76d3c33f648",
ToRevision: "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863",
@@ -215,11 +216,11 @@ func TestGetRawChangesManyFiles(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, repo, _, client := setupRepositoryService(t, ctx)
+ _, repoProto, _, client := setupRepositoryService(t, ctx)
initCommit := "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863"
req := &gitalypb.GetRawChangesRequest{
- Repository: repo,
+ Repository: repoProto,
FromRevision: initCommit,
ToRevision: "many_files",
}
@@ -236,10 +237,10 @@ func TestGetRawChangesMappingOperations(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, repo, _, client := setupRepositoryService(t, ctx)
+ _, repoProto, _, client := setupRepositoryService(t, ctx)
req := &gitalypb.GetRawChangesRequest{
- Repository: repo,
+ Repository: repoProto,
FromRevision: "1b12f15a11fc6e62177bef08f47bc7b5ce50b141",
ToRevision: "94bb47ca1297b7b3731ff2a36923640991e9236f",
}
@@ -278,7 +279,7 @@ func TestGetRawChangesInvalidUTF8Paths(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx)
+ cfg, repoProto, _, client := setupRepositoryService(t, ctx)
const (
// These are arbitrary blobs known to exist in the test repository
@@ -288,18 +289,18 @@ func TestGetRawChangesInvalidUTF8Paths(t *testing.T) {
)
require.False(t, utf8.ValidString(nonUTF8Filename)) // sanity check
- fromCommitID := WriteTestCommit(t, git, cfg, repoPath,
- git.WithTreeEntries(git.TreeEntry{
+ fromCommitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto),
+ localrepo.WithTreeEntries(git.TreeEntry{
OID: blobID1, Path: nonUTF8Filename, Mode: "100644",
}))
- toCommitID := WriteTestCommit(t, git, cfg, repoPath,
- git.WithTreeEntries(git.TreeEntry{
+ toCommitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto),
+ localrepo.WithTreeEntries(git.TreeEntry{
OID: blobID2, Path: nonUTF8Filename, Mode: "100644",
}))
req := &gitalypb.GetRawChangesRequest{
- Repository: repo,
+ Repository: repoProto,
FromRevision: fromCommitID.String(),
ToRevision: toCommitID.String(),
}
diff --git a/internal/gitaly/service/repository/rename_test.go b/internal/gitaly/service/repository/rename_test.go
index 84bedc2b2..45abd8685 100644
--- a/internal/gitaly/service/repository/rename_test.go
+++ b/internal/gitaly/service/repository/rename_test.go
@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v15/proto/go/gitalypb"
@@ -22,24 +23,24 @@ func TestRenameRepositorySuccess(t *testing.T) {
ctx := testhelper.Context(t)
- cfg, originalRepo, originalPath, client := setupRepositoryService(t, ctx)
+ cfg, originalRepoProto, originalPath, client := setupRepositoryService(t, ctx)
const targetPath = "a-new-location"
_, err := client.RenameRepository(ctx, &gitalypb.RenameRepositoryRequest{
- Repository: originalRepo,
+ Repository: originalRepoProto,
RelativePath: targetPath,
})
require.NoError(t, err)
// A repository should not exist with the previous relative path
exists, err := client.RepositoryExists(ctx, &gitalypb.RepositoryExistsRequest{
- Repository: originalRepo,
+ Repository: originalRepoProto,
})
require.NoError(t, err)
testhelper.ProtoEqual(t, &gitalypb.RepositoryExistsResponse{Exists: false}, exists)
// A repository should exist with the new relative path
- renamedRepo := &gitalypb.Repository{StorageName: originalRepo.StorageName, RelativePath: targetPath}
+ renamedRepo := &gitalypb.Repository{StorageName: originalRepoProto.StorageName, RelativePath: targetPath}
exists, err = client.RepositoryExists(ctx, &gitalypb.RepositoryExistsRequest{
Repository: renamedRepo,
})
@@ -74,7 +75,7 @@ func TestRenameRepositoryDestinationExists(t *testing.T) {
require.NoError(t, err)
destinationRepoPath := filepath.Join(cfg.Storages[0].Path, git.GetReplicaPath(t, ctx, cfg, existingDestinationRepo))
- commitID := WriteTestCommit(t, git, cfg, destinationRepoPath)
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, existingDestinationRepo))
_, err = client.RenameRepository(ctx, &gitalypb.RenameRepositoryRequest{
Repository: renamedRepo,
diff --git a/internal/gitaly/service/repository/repack_test.go b/internal/gitaly/service/repository/repack_test.go
index 462d3b042..918544c48 100644
--- a/internal/gitaly/service/repository/repack_test.go
+++ b/internal/gitaly/service/repository/repack_test.go
@@ -25,20 +25,21 @@ func TestRepackIncrementalSuccess(t *testing.T) {
ctx := testhelper.Context(t)
cfg, client := setupRepositoryServiceWithoutRepo(t)
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
+ repo := localrepo.NewTestRepo(t, cfg, repoProto)
// Bring the repository into a known-good state with a single packfile, only.
- initialCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"))
+ initialCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main"))
git.Exec(t, cfg, "-C", repoPath, "repack", "-Ad")
oldPackfileCount, err := stats.PackfilesCount(repoPath)
require.NoError(t, err)
require.Equal(t, 1, oldPackfileCount)
// Write a second commit into the repository so that we have something to repack.
- WriteTestCommit(t, git, cfg, repoPath, git.WithParents(initialCommit), git.WithBranch("main"))
+ localrepo.WriteTestCommit(t, repo, localrepo.WithParents(initialCommit), localrepo.WithBranch("main"))
//nolint:staticcheck
- c, err := client.RepackIncremental(ctx, &gitalypb.RepackIncrementalRequest{Repository: repo})
+ c, err := client.RepackIncremental(ctx, &gitalypb.RepackIncrementalRequest{Repository: repoProto})
assert.NoError(t, err)
assert.NotNil(t, c)
@@ -70,27 +71,28 @@ func TestRepackLocal(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx)
+ cfg, repoProto, repoPath, client := setupRepositoryService(t, ctx)
+ repo := localrepo.NewTestRepo(t, cfg, repoProto)
altObjectsDir := "./alt-objects"
- alternateCommit := git.WriteTestCommit(t, cfg, repoPath,
- git.WithMessage("alternate commit"),
- git.WithAlternateObjectDirectory(filepath.Join(repoPath, altObjectsDir)),
- git.WithBranch("alternate-odb"),
+ alternateCommit := localrepo.WriteTestCommit(t, repo,
+ localrepo.WithMessage("alternate commit"),
+ localrepo.WithAlternateObjectDirectory(filepath.Join(repoPath, altObjectsDir)),
+ localrepo.WithBranch("alternate-odb"),
)
- repoCommit := WriteTestCommit(t, git, cfg, repoPath,
- git.WithMessage("main commit"),
- git.WithBranch("main-odb"))
+ repoCommit := localrepo.WriteTestCommit(t, repo,
+ localrepo.WithMessage("main commit"),
+ localrepo.WithBranch("main-odb"))
// Set GIT_ALTERNATE_OBJECT_DIRECTORIES on the outgoing request. The
// intended use case of the behavior we're testing here is that
// alternates are found through the objects/info/alternates file instead
// of GIT_ALTERNATE_OBJECT_DIRECTORIES. But for the purpose of this test
// it doesn't matter.
- repo.GitAlternateObjectDirectories = []string{altObjectsDir}
+ repoProto.GitAlternateObjectDirectories = []string{altObjectsDir}
//nolint:staticcheck
- _, err := client.RepackFull(ctx, &gitalypb.RepackFullRequest{Repository: repo})
+ _, err := client.RepackFull(ctx, &gitalypb.RepackFullRequest{Repository: repoProto})
require.NoError(t, err)
packFiles, err := filepath.Glob(filepath.Join(repoPath, "objects", "pack", "pack-*.pack"))
@@ -185,12 +187,13 @@ func TestRepackFullSuccess(t *testing.T) {
t.Run(tc.desc, func(t *testing.T) {
t.Parallel()
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg)
+ repo := localrepo.NewTestRepo(t, cfg, repoProto)
// Bring the repository into a known state with two packfiles.
- WriteTestCommit(t, git, cfg, repoPath, git.WithMessage("first"), git.WithBranch("first"))
+ localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("first"), localrepo.WithBranch("first"))
git.Exec(t, cfg, "-C", repoPath, "repack")
- WriteTestCommit(t, git, cfg, repoPath, git.WithMessage("second"), git.WithBranch("second"))
+ localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("second"), localrepo.WithBranch("second"))
git.Exec(t, cfg, "-C", repoPath, "repack")
oldPackfileCount, err := stats.PackfilesCount(repoPath)
require.NoError(t, err)
@@ -198,7 +201,7 @@ func TestRepackFullSuccess(t *testing.T) {
//nolint:staticcheck
response, err := client.RepackFull(ctx, &gitalypb.RepackFullRequest{
- Repository: repo,
+ Repository: repoProto,
CreateBitmap: tc.createBitmap,
})
require.NoError(t, err)
@@ -303,12 +306,12 @@ func TestRepackFullDeltaIslands(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx)
- localRepo := localrepo.NewTestRepo(t, cfg, repo)
+ cfg, repoProto, _, client := setupRepositoryService(t, ctx)
+ repo := localrepo.NewTestRepo(t, cfg, repoProto)
localrepo.TestDeltaIslands(t, cfg, repo, repo, false, func() error {
//nolint:staticcheck
- _, err := client.RepackFull(ctx, &gitalypb.RepackFullRequest{Repository: repo})
+ _, err := client.RepackFull(ctx, &gitalypb.RepackFullRequest{Repository: repoProto})
return err
})
}
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index babad16ac..966e10390 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -49,7 +49,7 @@ func TestReplicateRepository(t *testing.T) {
client, serverSocketPath := runRepositoryService(t, cfg, nil)
cfg.SocketPath = serverSocketPath
- repo, repoPath := git.CreateRepository(t, ctx, cfg, git.CreateRepositoryConfig{
+ repoProto, repoPath := git.CreateRepository(t, ctx, cfg, git.CreateRepositoryConfig{
Seed: git.SeedGitLabTest,
})
@@ -71,14 +71,14 @@ func TestReplicateRepository(t *testing.T) {
configData := testhelper.MustReadFile(t, filepath.Join(repoPath, "config"))
require.Contains(t, string(configData), "[please]\n\treplicate = me\n")
- targetRepo := proto.Clone(repo).(*gitalypb.Repository)
+ targetRepo := proto.Clone(repoProto).(*gitalypb.Repository)
targetRepo.StorageName = cfg.Storages[1].Name
ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg))
_, err = client.ReplicateRepository(ctx, &gitalypb.ReplicateRepositoryRequest{
Repository: targetRepo,
- Source: repo,
+ Source: repoProto,
})
require.NoError(t, err)
@@ -95,10 +95,10 @@ func TestReplicateRepository(t *testing.T) {
require.Equal(t, string(configData), string(replicatedConfigData), "config files must match")
// create another branch
- WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("branch"))
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithBranch("branch"))
_, err = client.ReplicateRepository(ctx, &gitalypb.ReplicateRepositoryRequest{
Repository: targetRepo,
- Source: repo,
+ Source: repoProto,
})
require.NoError(t, err)
require.Equal(t,
@@ -126,23 +126,23 @@ func TestReplicateRepository_hiddenRefs(t *testing.T) {
ctx = testhelper.MergeOutgoingMetadata(ctx, testcfg.GitalyServersMetadataFromCfg(t, cfg))
t.Run("initial seeding", func(t *testing.T) {
- sourceRepo, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ sourceRepoProto, sourceRepoProtoPath := git.CreateRepository(t, ctx, cfg)
// Create a bunch of internal references, regardless of whether we classify them as hidden
// or read-only. We should be able to replicate all of them.
var expectedRefs []string
for refPrefix := range git.InternalRefPrefixes {
- commitID := WriteTestCommit(t, git, cfg, sourceRepoPath, git.WithParents(), git.WithMessage(refPrefix))
- git.Exec(t, cfg, "-C", sourceRepoPath, "update-ref", refPrefix+"1", commitID.String())
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, sourceRepoProto), localrepo.WithParents(), localrepo.WithMessage(refPrefix))
+ git.Exec(t, cfg, "-C", sourceRepoProtoPath, "update-ref", refPrefix+"1", commitID.String())
expectedRefs = append(expectedRefs, fmt.Sprintf("%s commit\t%s", commitID, refPrefix+"1"))
}
- targetRepo := proto.Clone(sourceRepo).(*gitalypb.Repository)
+ targetRepo := proto.Clone(sourceRepoProto).(*gitalypb.Repository)
targetRepo.StorageName = cfg.Storages[1].Name
_, err := client.ReplicateRepository(ctx, &gitalypb.ReplicateRepositoryRequest{
Repository: targetRepo,
- Source: sourceRepo,
+ Source: sourceRepoProto,
})
require.NoError(t, err)
@@ -152,27 +152,29 @@ func TestReplicateRepository_hiddenRefs(t *testing.T) {
// Perform another sanity-check to verify that source and target repository have the
// same references now.
require.Equal(t,
- text.ChompBytes(git.Exec(t, cfg, "-C", sourceRepoPath, "for-each-ref")),
+ text.ChompBytes(git.Exec(t, cfg, "-C", sourceRepoProtoPath, "for-each-ref")),
text.ChompBytes(git.Exec(t, cfg, "-C", targetRepoPath, "for-each-ref")),
)
})
t.Run("incremental replication", func(t *testing.T) {
- sourceRepo, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
- targetRepo, targetRepoPath := git.CreateRepository(t, ctx, cfg, git.CreateRepositoryConfig{
- RelativePath: sourceRepo.GetRelativePath(),
+ sourceRepoProto, sourceRepoPath := git.CreateRepository(t, ctx, cfg)
+ targetRepoProto, targetRepoPath := git.CreateRepository(t, ctx, cfg, git.CreateRepositoryConfig{
+ RelativePath: sourceRepoProto.GetRelativePath(),
Storage: cfg.Storages[1],
})
+ sourceRepo := localrepo.NewTestRepo(t, cfg, sourceRepoProto)
+
// Create the same commit in both repositories so that they're in a known-good
// state.
- sourceCommitID := git.WriteTestCommit(t, cfg, sourceRepoPath, git.WithParents(), git.WithMessage("base"), git.WithBranch("main"))
- targetCommitID := git.WriteTestCommit(t, cfg, targetRepoPath, git.WithParents(), git.WithMessage("base"), git.WithBranch("main"))
+ sourceCommitID := localrepo.WriteTestCommit(t, sourceRepo, localrepo.WithParents(), localrepo.WithMessage("base"), localrepo.WithBranch("main"))
+ targetCommitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, targetRepoProto), localrepo.WithParents(), localrepo.WithMessage("base"), localrepo.WithBranch("main"))
require.Equal(t, sourceCommitID, targetCommitID)
// Create the internal references now.
for refPrefix := range git.InternalRefPrefixes {
- commitID := WriteTestCommit(t, git, cfg, sourceRepoPath, git.WithParents(), git.WithMessage(refPrefix))
+ commitID := localrepo.WriteTestCommit(t, sourceRepo, localrepo.WithParents(), localrepo.WithMessage(refPrefix))
git.Exec(t, cfg, "-C", sourceRepoPath, "update-ref", refPrefix+"1", commitID.String())
}
@@ -180,8 +182,8 @@ func TestReplicateRepository_hiddenRefs(t *testing.T) {
// Because the target repository exists already we'll do a fetch instead of
// replicating via an archive.
_, err := client.ReplicateRepository(ctx, &gitalypb.ReplicateRepositoryRequest{
- Repository: targetRepo,
- Source: sourceRepo,
+ Repository: targetRepoProto,
+ Source: sourceRepoProto,
})
require.NoError(t, err)
@@ -545,9 +547,9 @@ func TestFetchInternalRemote_successful(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- remoteCfg, remoteRepo, remoteRepoPath := testcfg.BuildWithRepo(t)
+ remoteCfg, remoteRepoProto, remoteRepoPath := testcfg.BuildWithRepo(t)
testcfg.BuildGitalyHooks(t, remoteCfg)
- WriteTestCommit(t, git, remoteCfg, remoteRepoPath, git.WithBranch("master"))
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, remoteCfg, remoteRepoProto), localrepo.WithBranch("master"))
_, remoteAddr := runRepositoryService(t, remoteCfg, nil, testserver.WithDisablePraefect())
@@ -573,7 +575,7 @@ func TestFetchInternalRemote_successful(t *testing.T) {
}),
))
- ctx, err := storage.InjectGitalyServers(ctx, remoteRepo.GetStorageName(), remoteAddr, remoteCfg.Auth.Token)
+ ctx, err := storage.InjectGitalyServers(ctx, remoteRepoProto.GetStorageName(), remoteAddr, remoteCfg.Auth.Token)
require.NoError(t, err)
ctx = metadata.OutgoingToIncoming(ctx)
@@ -584,7 +586,7 @@ func TestFetchInternalRemote_successful(t *testing.T) {
// Use the `assert` package such that we can get information about why hooks have failed via
// the hook logs in case it did fail unexpectedly.
- assert.NoError(t, fetchInternalRemote(ctx, &transaction.MockManager{}, connsPool, localRepo, remoteRepo))
+ assert.NoError(t, fetchInternalRemote(ctx, &transaction.MockManager{}, connsPool, localRepo, remoteRepoProto))
hookLogs := filepath.Join(localCfg.Logging.Dir, "gitaly_hooks.log")
require.FileExists(t, hookLogs)
diff --git a/internal/gitaly/service/repository/ruby_sidecar_test.go b/internal/gitaly/service/repository/ruby_sidecar_test.go
index 20fed5e0c..96c1f525b 100644
--- a/internal/gitaly/service/repository/ruby_sidecar_test.go
+++ b/internal/gitaly/service/repository/ruby_sidecar_test.go
@@ -8,6 +8,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/v15/internal/testhelper/testcfg"
diff --git a/internal/gitaly/service/repository/search_files_test.go b/internal/gitaly/service/repository/search_files_test.go
index cae8c214b..b57b9f932 100644
--- a/internal/gitaly/service/repository/search_files_test.go
+++ b/internal/gitaly/service/repository/search_files_test.go
@@ -14,6 +14,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/catfile"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/housekeeping"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/transaction"
@@ -88,7 +89,7 @@ func TestSearchFilesByContentSuccessful(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, repo, _, client := setupRepositoryService(t, ctx)
+ _, repoProto, _, client := setupRepositoryService(t, ctx)
testCases := []struct {
desc string
@@ -131,7 +132,7 @@ func TestSearchFilesByContentSuccessful(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
request := &gitalypb.SearchFilesByContentRequest{
- Repository: repo,
+ Repository: repoProto,
Query: tc.query,
Ref: []byte(tc.ref),
}
@@ -154,7 +155,7 @@ func TestSearchFilesByContentLargeFile(t *testing.T) {
ctx := testhelper.Context(t)
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx)
+ cfg, repoProto, _, client := setupRepositoryService(t, ctx)
for _, tc := range []struct {
desc string
@@ -179,14 +180,14 @@ func TestSearchFilesByContentLargeFile(t *testing.T) {
},
} {
t.Run(tc.filename, func(t *testing.T) {
- WriteTestCommit(t, git, cfg, repoPath, git.WithTreeEntries(git.TreeEntry{
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithTreeEntries(git.TreeEntry{
Path: tc.filename,
Mode: "100644",
Content: strings.Repeat(tc.line, tc.repeated),
- }), git.WithBranch("master"))
+ }), localrepo.WithBranch("master"))
stream, err := client.SearchFilesByContent(ctx, &gitalypb.SearchFilesByContentRequest{
- Repository: repo,
+ Repository: repoProto,
Query: tc.query,
Ref: []byte("master"),
ChunkedResponse: true,
@@ -203,7 +204,7 @@ func TestSearchFilesByContentLargeFile(t *testing.T) {
func TestSearchFilesByContentFailure(t *testing.T) {
t.Parallel()
- cfg, repo, _ := testcfg.BuildWithRepo(t)
+ cfg, repoProto, _ := testcfg.BuildWithRepo(t)
gitCommandFactory := git.NewCommandFactory(t, cfg)
catfileCache := catfile.NewCache(cfg)
t.Cleanup(catfileCache.Stop)
@@ -239,13 +240,13 @@ func TestSearchFilesByContentFailure(t *testing.T) {
}{
{
desc: "empty request",
- repo: repo,
+ repo: repoProto,
code: codes.InvalidArgument,
msg: "no query given",
},
{
desc: "only query given",
- repo: repo,
+ repo: repoProto,
query: "foo",
code: codes.InvalidArgument,
msg: "no ref given",
@@ -259,7 +260,7 @@ func TestSearchFilesByContentFailure(t *testing.T) {
},
{
desc: "invalid ref argument",
- repo: repo,
+ repo: repoProto,
query: ".",
ref: "--no-index",
code: codes.InvalidArgument,
@@ -285,7 +286,7 @@ func TestSearchFilesByNameSuccessful(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- _, repo, _, client := setupRepositoryService(t, ctx)
+ _, repoProto, _, client := setupRepositoryService(t, ctx)
testCases := []struct {
desc string
@@ -328,7 +329,7 @@ func TestSearchFilesByNameSuccessful(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
stream, err := client.SearchFilesByName(ctx, &gitalypb.SearchFilesByNameRequest{
- Repository: repo,
+ Repository: repoProto,
Ref: tc.ref,
Query: tc.query,
Filter: tc.filter,
@@ -351,13 +352,13 @@ func TestSearchFilesByNameUnusualFileNamesSuccessful(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx)
+ cfg, repoProto, _, client := setupRepositoryService(t, ctx)
ref := []byte("unusual_file_names")
- git.WriteTestCommit(t, cfg, repoPath,
- git.WithBranch(string(ref)),
- git.WithMessage("commit message"),
- git.WithTreeEntries(
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto),
+ localrepo.WithBranch(string(ref)),
+ localrepo.WithMessage("commit message"),
+ localrepo.WithTreeEntries(
git.TreeEntry{Path: "\"file with quote.txt", Mode: "100644", Content: "something"},
git.TreeEntry{Path: ".vimrc", Mode: "100644", Content: "something"},
git.TreeEntry{Path: "cuộc đời là những chuyến đi.md", Mode: "100644", Content: "something"},
@@ -430,7 +431,7 @@ func TestSearchFilesByNameUnusualFileNamesSuccessful(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
stream, err := client.SearchFilesByName(ctx, &gitalypb.SearchFilesByNameRequest{
- Repository: repo,
+ Repository: repoProto,
Ref: ref,
Query: tc.query,
Filter: tc.filter,
@@ -449,13 +450,13 @@ func TestSearchFilesByNamePaginationSuccessful(t *testing.T) {
t.Parallel()
ctx := testhelper.Context(t)
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx)
+ cfg, repoProto, _, client := setupRepositoryService(t, ctx)
ref := []byte("pagination")
- git.WriteTestCommit(t, cfg, repoPath,
- git.WithBranch(string(ref)),
- git.WithMessage("commit message"),
- git.WithTreeEntries(
+ localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto),
+ localrepo.WithBranch(string(ref)),
+ localrepo.WithMessage("commit message"),
+ localrepo.WithTreeEntries(
git.TreeEntry{Path: "file1.md", Mode: "100644", Content: "file1"},
git.TreeEntry{Path: "file2.md", Mode: "100644", Content: "file2"},
git.TreeEntry{Path: "file3.md", Mode: "100644", Content: "file3"},
@@ -534,7 +535,7 @@ func TestSearchFilesByNamePaginationSuccessful(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
stream, err := client.SearchFilesByName(ctx, &gitalypb.SearchFilesByNameRequest{
- Repository: repo,
+ Repository: repoProto,
Ref: ref,
Query: tc.query,
Filter: tc.filter,
diff --git a/internal/gitaly/service/repository/size_test.go b/internal/gitaly/service/repository/size_test.go
index b3dcf9207..6b2cc5126 100644
--- a/internal/gitaly/service/repository/size_test.go
+++ b/internal/gitaly/service/repository/size_test.go
@@ -13,6 +13,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/catfile"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/git/quarantine"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v15/internal/metadata/featureflag"
@@ -107,9 +108,9 @@ func testSuccessfulRepositorySizeRequest(t *testing.T, ctx context.Context) {
t.Parallel()
logger, hook := test.NewNullLogger()
- cfg, repo, repoPath, client := setupRepositoryService(t, ctx, testserver.WithLogger(logger))
+ cfg, repoProto, repoPath, client := setupRepositoryService(t, ctx, testserver.WithLogger(logger))
- request := &gitalypb.RepositorySizeRequest{Repository: repo}
+ request := &gitalypb.RepositorySizeRequest{Repository: repoProto}
response, err := client.RepositorySize(ctx, request)
require.NoError(t, err)
@@ -127,7 +128,7 @@ func testSuccessfulRepositorySizeRequest(t *testing.T, ctx context.Context) {
Path: "1kbblob",
},
})
- commitOID := WriteTestCommit(t, git, cfg, repoPath, git.WithTree(treeOID))
+ commitOID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithTree(treeOID))
git.WriteRef(t, cfg, repoPath, git.ReferenceName("refs/keep-around/keep1"), commitOID)
git.WriteRef(t, cfg, repoPath, git.ReferenceName("refs/merge-requests/1123"), commitOID)
diff --git a/internal/gitaly/service/repository/snapshot_test.go b/internal/gitaly/service/repository/snapshot_test.go
index af286c53b..a442b11ee 100644
--- a/internal/gitaly/service/repository/snapshot_test.go
+++ b/internal/gitaly/service/repository/snapshot_test.go
@@ -50,11 +50,11 @@ func touch(t *testing.T, format string, args ...interface{}) {
func TestGetSnapshotSuccess(t *testing.T) {
t.Parallel()
- cfg, repo, repoPath, client := setupRepositoryService(t, testhelper.Context(t))
+ cfg, repoProto, repoPath, client := setupRepositoryService(t, testhelper.Context(t))
// Ensure certain files exist in the test repo.
// WriteCommit produces a loose object with the given sha
- sha := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"))
+ sha := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithBranch("master"))
zeroes := strings.Repeat("0", 40)
require.NoError(t, os.MkdirAll(filepath.Join(repoPath, "hooks"), 0o755))
require.NoError(t, os.MkdirAll(filepath.Join(repoPath, "objects/pack"), 0o755))
@@ -63,7 +63,7 @@ func TestGetSnapshotSuccess(t *testing.T) {
touch(t, filepath.Join(repoPath, "objects/pack/pack-%s.idx"), zeroes)
touch(t, filepath.Join(repoPath, "objects/this-should-not-be-included"))
- req := &gitalypb.GetSnapshotRequest{Repository: repo}
+ req := &gitalypb.GetSnapshotRequest{Repository: repoProto}
data, err := getSnapshot(t, client, req)
require.NoError(t, err)
@@ -122,9 +122,9 @@ func TestGetSnapshotWithDedupe(t *testing.T) {
absoluteAlternateObjDir = filepath.Join(repoPath, "objects", alternateObjDir)
}
- firstCommitID := WriteTestCommit(t, git, cfg, repoPath,
- git.WithMessage("An empty commit"),
- git.WithAlternateObjectDirectory(absoluteAlternateObjDir))
+ firstCommitID := localrepo.WriteTestCommit(t, repo,
+ localrepo.WithMessage("An empty commit"),
+ localrepo.WithAlternateObjectDirectory(absoluteAlternateObjDir))
locator := config.NewLocator(cfg)
@@ -138,9 +138,9 @@ func TestGetSnapshotWithDedupe(t *testing.T) {
require.NoError(t, os.WriteFile(alternatesPath, []byte(fmt.Sprintf("%s\n", alternateObjDir)), 0o644))
// Write another commit into the alternate object directory.
- secondCommitID := WriteTestCommit(t, git, cfg, repoPath,
- git.WithMessage("Another empty commit"),
- git.WithAlternateObjectDirectory(absoluteAlternateObjDir))
+ secondCommitID := localrepo.WriteTestCommit(t, repo,
+ localrepo.WithMessage("Another empty commit"),
+ localrepo.WithAlternateObjectDirectory(absoluteAlternateObjDir))
// We should now be able to find both commits given that the alternates file
// points to the object directory we've created them in.
@@ -214,10 +214,9 @@ func TestGetSnapshot_alternateObjectDirectory(t *testing.T) {
t.Run("valid alternate object directory", func(t *testing.T) {
alternateObjectDir := filepath.Join(repoPath, "valid-odb")
- commitID := WriteTestCommit(t, git, cfg, repoPath,
- git.WithAlternateObjectDirectory(alternateObjectDir),
-
- git.WithBranch("some-branch"))
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto),
+ localrepo.WithAlternateObjectDirectory(alternateObjectDir),
+ localrepo.WithBranch("some-branch"))
require.NoError(t, os.WriteFile(alternatesFile, []byte(alternateObjectDir), 0o644))
defer func() {
@@ -300,14 +299,14 @@ func TestGetSnapshot_validate(t *testing.T) {
func TestGetSnapshotFailsIfRepositoryContainsSymlink(t *testing.T) {
t.Parallel()
- _, repo, repoPath, client := setupRepositoryService(t, testhelper.Context(t))
+ _, repoProto, repoPath, client := setupRepositoryService(t, testhelper.Context(t))
// Make packed-refs into a symlink to break GetSnapshot()
packedRefsFile := filepath.Join(repoPath, "packed-refs")
require.NoError(t, os.Remove(packedRefsFile))
require.NoError(t, os.Symlink("HEAD", packedRefsFile))
- req := &gitalypb.GetSnapshotRequest{Repository: repo}
+ req := &gitalypb.GetSnapshotRequest{Repository: repoProto}
data, err := getSnapshot(t, client, req)
testhelper.RequireGrpcCode(t, err, codes.Internal)
require.Contains(t, err.Error(), "building snapshot failed")
diff --git a/internal/gitaly/service/repository/write_ref_test.go b/internal/gitaly/service/repository/write_ref_test.go
index 86ad76a5f..15dc2fc3d 100644
--- a/internal/gitaly/service/repository/write_ref_test.go
+++ b/internal/gitaly/service/repository/write_ref_test.go
@@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v15/internal/git"
+ "gitlab.com/gitlab-org/gitaly/v15/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v15/internal/helper/text"
"gitlab.com/gitlab-org/gitaly/v15/internal/metadata"
@@ -201,8 +202,8 @@ func TestWriteRef_missingRevisions(t *testing.T) {
ctx := testhelper.Context(t)
cfg, client := setupRepositoryServiceWithoutRepo(t)
- repo, repoPath := git.CreateRepository(t, ctx, cfg)
- commitID := WriteTestCommit(t, git, cfg, repoPath)
+ repoProto, _ := git.CreateRepository(t, ctx, cfg)
+ commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto))
for _, tc := range []struct {
desc string
@@ -212,7 +213,7 @@ func TestWriteRef_missingRevisions(t *testing.T) {
{
desc: "revision refers to missing reference",
request: &gitalypb.WriteRefRequest{
- Repository: repo,
+ Repository: repoProto,
Ref: []byte("refs/heads/main"),
Revision: []byte("refs/heads/missing"),
},
@@ -221,7 +222,7 @@ func TestWriteRef_missingRevisions(t *testing.T) {
{
desc: "revision refers to missing object",
request: &gitalypb.WriteRefRequest{
- Repository: repo,
+ Repository: repoProto,
Ref: []byte("refs/heads/main"),
Revision: bytes.Repeat([]byte("1"), git.DefaultObjectHash.EncodedLen()),
},
@@ -230,7 +231,7 @@ func TestWriteRef_missingRevisions(t *testing.T) {
{
desc: "old revision refers to missing reference",
request: &gitalypb.WriteRefRequest{
- Repository: repo,
+ Repository: repoProto,
Ref: []byte("refs/heads/main"),
Revision: []byte(commitID),
OldRevision: bytes.Repeat([]byte("1"), git.DefaultObjectHash.EncodedLen()),