diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-05-09 18:05:54 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2021-05-17 16:44:20 +0300 |
commit | ad907a414ed81d0ca65ac48f88d97c0e6bd0d3c6 (patch) | |
tree | 4da4081f82e9daa499ef48ffe468f086d90c6511 | |
parent | a7135eb9f8b9bdd550af154b2a291dc097bf13ba (diff) |
Break dependency of the CloneRepoAtStorage on the global config.Config
In order to get rid of the global variable config.Config we change
CloneRepoAtStorage function to accept config.Cfg as an input parameter.
We use locally defined instance of the config.Cfg type to call modified
function, so the usage of it is no longer depend on the config.Config
variable.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
49 files changed, 93 insertions, 93 deletions
diff --git a/cmd/gitaly-backup/create_test.go b/cmd/gitaly-backup/create_test.go index e14944dda..ba0a537c7 100644 --- a/cmd/gitaly-backup/create_test.go +++ b/cmd/gitaly-backup/create_test.go @@ -28,7 +28,7 @@ func TestCreateSubcommand(t *testing.T) { var repos []*gitalypb.Repository for i := 0; i < 5; i++ { - repo, _, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], fmt.Sprintf("repo-%d", i)) + repo, _, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], fmt.Sprintf("repo-%d", i)) repos = append(repos, repo) } diff --git a/cmd/gitaly-backup/restore_test.go b/cmd/gitaly-backup/restore_test.go index fcc4340d2..583e15c7c 100644 --- a/cmd/gitaly-backup/restore_test.go +++ b/cmd/gitaly-backup/restore_test.go @@ -27,7 +27,7 @@ func TestRestoreSubcommand(t *testing.T) { path := testhelper.TempDir(t) - existingRepo, existRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "existing_repo") + existingRepo, existRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "existing_repo") existingRepoBundlePath := filepath.Join(path, existingRepo.RelativePath+".bundle") gittest.Exec(t, cfg, "-C", existRepoPath, "bundle", "create", existingRepoBundlePath, "--all") diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go index b9b40a2e8..b41fe48ee 100644 --- a/cmd/gitaly-hooks/hooks_test.go +++ b/cmd/gitaly-hooks/hooks_test.go @@ -269,7 +269,7 @@ func TestHooksUpdate(t *testing.T) { } func testHooksUpdate(t *testing.T, cfg config.Cfg, glValues glHookValues) { - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) refval, oldval, newval := "refval", strings.Repeat("a", 40), strings.Repeat("b", 40) diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go index d1f078711..908898002 100644 --- a/internal/backup/backup_test.go +++ b/internal/backup/backup_test.go @@ -24,11 +24,11 @@ func TestFilesystem_BackupRepository(t *testing.T) { path := testhelper.TempDir(t) - hooksRepo, hooksRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "hooks") + hooksRepo, hooksRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "hooks") require.NoError(t, os.Mkdir(filepath.Join(hooksRepoPath, "custom_hooks"), os.ModePerm)) require.NoError(t, ioutil.WriteFile(filepath.Join(hooksRepoPath, "custom_hooks/pre-commit.sample"), []byte("Some hooks"), os.ModePerm)) - noHooksRepo, _, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "no-hooks") + noHooksRepo, _, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "no-hooks") emptyRepo, _, _ := gittest.InitBareRepoAt(t, cfg, cfg.Storages[0]) nonexistentRepo := *emptyRepo nonexistentRepo.RelativePath = "nonexistent" @@ -109,7 +109,7 @@ func TestFilesystem_RestoreRepository(t *testing.T) { path := testhelper.TempDir(t) - existingRepo, existRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "existing_repo") + existingRepo, existRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "existing_repo") existingRepoPath := filepath.Join(path, existingRepo.RelativePath) existingRepoBundlePath := existingRepoPath + ".bundle" existingRepoCustomHooksPath := filepath.Join(existingRepoPath, "custom_hooks.tar") diff --git a/internal/cache/cache_test.go b/internal/cache/cache_test.go index 7dd96fc96..fe775b14b 100644 --- a/internal/cache/cache_test.go +++ b/internal/cache/cache_test.go @@ -22,8 +22,8 @@ import ( func TestStreamDBNaiveKeyer(t *testing.T) { cfg := testcfg.Build(t) - testRepo1, _, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "repository-1") - testRepo2, _, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "repository-2") + testRepo1, _, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "repository-1") + testRepo2, _, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "repository-2") locator := config.NewLocator(cfg) diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go index f7c0f9cda..debc7464f 100644 --- a/internal/git/gittest/repo.go +++ b/internal/git/gittest/repo.go @@ -103,8 +103,8 @@ func CloneRepoAtStorageRoot(t testing.TB, cfg config.Cfg, storageRoot, relativeP } // CloneRepoAtStorage clones a new copy of test repository under a subdirectory in the storage root. -func CloneRepoAtStorage(t testing.TB, storage config.Storage, relativePath string) (*gitalypb.Repository, string, testhelper.Cleanup) { - repo, repoPath, cleanup := cloneRepo(t, config.Config, storage.Path, relativePath, testRepo, true) +func CloneRepoAtStorage(t testing.TB, cfg config.Cfg, storage config.Storage, relativePath string) (*gitalypb.Repository, string, testhelper.Cleanup) { + repo, repoPath, cleanup := cloneRepo(t, cfg, storage.Path, relativePath, testRepo, true) repo.StorageName = storage.Name return repo, repoPath, cleanup } diff --git a/internal/git/gittest/repository_suite.go b/internal/git/gittest/repository_suite.go index 35c6a9c0d..9f1580361 100644 --- a/internal/git/gittest/repository_suite.go +++ b/internal/git/gittest/repository_suite.go @@ -36,7 +36,7 @@ func testRepositoryResolveRevision(t *testing.T, cfg config.Cfg, getRepository f ctx, cancel := testhelper.Context() defer cancel() - pbRepo, _, _ := CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + pbRepo, _, _ := CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) for _, tc := range []struct { desc string diff --git a/internal/git/gittest/testhelper_test.go b/internal/git/gittest/testhelper_test.go index 9d47cb9a8..01008107b 100644 --- a/internal/git/gittest/testhelper_test.go +++ b/internal/git/gittest/testhelper_test.go @@ -50,7 +50,7 @@ func setup(t testing.TB) (config.Cfg, *gitalypb.Repository, string) { require.NoError(t, testhelper.ConfigureRuby(&cfg)) require.NoError(t, cfg.Validate()) - repo, repoPath, cleanup := CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup := CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) return cfg, repo, repoPath diff --git a/internal/git/localrepo/objects_test.go b/internal/git/localrepo/objects_test.go index 770a65c74..e2dec327c 100644 --- a/internal/git/localrepo/objects_test.go +++ b/internal/git/localrepo/objects_test.go @@ -33,7 +33,7 @@ func setupRepo(t *testing.T, bare bool) (*Repo, string) { if bare { repoProto, repoPath, repoCleanUp = gittest.InitBareRepoAt(t, cfg, cfg.Storages[0]) } else { - repoProto, repoPath, repoCleanUp = gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repoProto, repoPath, repoCleanUp = gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) } t.Cleanup(repoCleanUp) diff --git a/internal/git/localrepo/refs_test.go b/internal/git/localrepo/refs_test.go index 918748d4c..1a5de4515 100644 --- a/internal/git/localrepo/refs_test.go +++ b/internal/git/localrepo/refs_test.go @@ -400,7 +400,7 @@ func TestRepo_UpdateRef(t *testing.T) { for _, tc := range testcases { t.Run(tc.desc, func(t *testing.T) { // Re-create repo for each testcase. - repoProto, _, _ := gittest.CloneRepoAtStorage(t, repo.cfg.Storages[0], t.Name()) + repoProto, _, _ := gittest.CloneRepoAtStorage(t, repo.cfg, repo.cfg.Storages[0], t.Name()) repo := New(repo.gitCmdFactory, repo.catfileCache, repoProto, repo.cfg) err := repo.UpdateRef(ctx, git.ReferenceName(tc.ref), tc.newValue, tc.oldValue) tc.verify(t, repo, err) diff --git a/internal/git/localrepo/remote_test.go b/internal/git/localrepo/remote_test.go index f8f511225..91fbc6a3f 100644 --- a/internal/git/localrepo/remote_test.go +++ b/internal/git/localrepo/remote_test.go @@ -35,7 +35,7 @@ func setupRepoRemote(t *testing.T, bare bool) (Remote, string) { if bare { repoProto, repoPath, repoCleanUp = gittest.InitBareRepoAt(t, cfg, cfg.Storages[0]) } else { - repoProto, repoPath, repoCleanUp = gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repoProto, repoPath, repoCleanUp = gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) } t.Cleanup(repoCleanUp) @@ -98,7 +98,7 @@ func TestRemote_Add(t *testing.T) { gittest.Exec(t, remote.repo.cfg, "-C", repoPath, "remote", "remove", "origin") - _, remoteRepoPath, cleanup := gittest.CloneRepoAtStorage(t, remote.repo.cfg.Storages[0], "repository") + _, remoteRepoPath, cleanup := gittest.CloneRepoAtStorage(t, remote.repo.cfg, remote.repo.cfg.Storages[0], "repository") defer cleanup() t.Run("invalid argument", func(t *testing.T) { @@ -359,8 +359,8 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("with env", func(t *testing.T) { - _, sourceRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()+"-1") - testRepo, testRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()+"-2") + _, sourceRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()+"-1") + testRepo, testRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()+"-2") repo := New(remoteCmd.repo.gitCmdFactory, remoteCmd.repo.catfileCache, testRepo, cfg) gittest.Exec(t, cfg, "-C", testRepoPath, "remote", "add", "source", sourceRepoPath) @@ -371,8 +371,8 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("with globals", func(t *testing.T) { - _, sourceRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()+"-1") - testRepo, testRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()+"-2") + _, sourceRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()+"-1") + testRepo, testRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()+"-2") repo := New(remoteCmd.repo.gitCmdFactory, remoteCmd.repo.catfileCache, testRepo, cfg) gittest.Exec(t, cfg, "-C", testRepoPath, "remote", "add", "source", sourceRepoPath) @@ -398,8 +398,8 @@ func TestRepo_FetchRemote(t *testing.T) { }) t.Run("with prune", func(t *testing.T) { - _, sourceRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()+"-1") - testRepo, testRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()+"-2") + _, sourceRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()+"-1") + testRepo, testRepoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()+"-2") repo := New(remoteCmd.repo.gitCmdFactory, remoteCmd.repo.catfileCache, testRepo, cfg) diff --git a/internal/git/stats/git_test.go b/internal/git/stats/git_test.go index 05ac2ccb4..5056e84ba 100644 --- a/internal/git/stats/git_test.go +++ b/internal/git/stats/git_test.go @@ -23,10 +23,10 @@ import ( func TestLogObjectInfo(t *testing.T) { cfg := testcfg.Build(t) - repo1, repoPath1, cleanup1 := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()+"-1") + repo1, repoPath1, cleanup1 := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()+"-1") defer cleanup1() - repo2, repoPath2, cleanup2 := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()+"-2") + repo2, repoPath2, cleanup2 := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()+"-2") defer cleanup2() ctx, cancel := testhelper.Context() diff --git a/internal/gitaly/service/blob/lfs_pointers_test.go b/internal/gitaly/service/blob/lfs_pointers_test.go index 9e3e63d07..323326ccc 100644 --- a/internal/gitaly/service/blob/lfs_pointers_test.go +++ b/internal/gitaly/service/blob/lfs_pointers_test.go @@ -380,7 +380,7 @@ func TestFindLFSPointersByRevisions(t *testing.T) { gitCmdFactory := git.NewExecCommandFactory(cfg) - repoProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repoProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) repo := localrepo.NewTestRepo(t, cfg, repoProto) diff --git a/internal/gitaly/service/blob/testhelper_test.go b/internal/gitaly/service/blob/testhelper_test.go index 8b99b8752..b9de56f3a 100644 --- a/internal/gitaly/service/blob/testhelper_test.go +++ b/internal/gitaly/service/blob/testhelper_test.go @@ -31,7 +31,7 @@ func testMain(m *testing.M) int { func setup(t *testing.T) (config.Cfg, *gitalypb.Repository, string, gitalypb.BlobServiceClient) { cfg := testcfg.Build(t) - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) addr := testserver.RunGitalyServer(t, cfg, nil, func(srv *grpc.Server, deps *service.Dependencies) { diff --git a/internal/gitaly/service/commit/testhelper_test.go b/internal/gitaly/service/commit/testhelper_test.go index e3f11d8bb..fe593096a 100644 --- a/internal/gitaly/service/commit/testhelper_test.go +++ b/internal/gitaly/service/commit/testhelper_test.go @@ -42,7 +42,7 @@ func setupCommitServiceWithRepo( ) (config.Cfg, *gitalypb.Repository, string, gitalypb.CommitServiceClient) { return setupCommitServiceCreateRepo(t, func(tb testing.TB, cfg config.Cfg) (*gitalypb.Repository, string, testhelper.Cleanup) { if bare { - return gittest.CloneRepoAtStorage(tb, cfg.Storages[0], t.Name()) + return gittest.CloneRepoAtStorage(tb, cfg, cfg.Storages[0], t.Name()) } return gittest.CloneRepoWithWorktreeAtStorage(tb, cfg, cfg.Storages[0]) }) diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go index 158c0185c..6fb7c8114 100644 --- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go +++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go @@ -177,7 +177,7 @@ func TestResolveConflictsWithRemoteRepo(t *testing.T) { testhelper.ConfigureGitalySSHBin(t, cfg) testhelper.ConfigureGitalyHooksBin(t, cfg) - sourceRepo, sourceRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "source") + sourceRepo, sourceRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "source") t.Cleanup(cleanup) sourceBlobOID := gittest.WriteBlob(t, cfg, sourceRepoPath, []byte("contents-1\n")) sourceCommitOID := gittest.WriteCommit(t, cfg, sourceRepoPath, @@ -187,7 +187,7 @@ func TestResolveConflictsWithRemoteRepo(t *testing.T) { ) gittest.Exec(t, cfg, "-C", sourceRepoPath, "update-ref", "refs/heads/source", sourceCommitOID.String()) - targetRepo, targetRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "target") + targetRepo, targetRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "target") t.Cleanup(cleanup) targetBlobOID := gittest.WriteBlob(t, cfg, targetRepoPath, []byte("contents-2\n")) targetCommitOID := gittest.WriteCommit(t, cfg, targetRepoPath, diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go index 35cd6803b..ee1e1d54c 100644 --- a/internal/gitaly/service/conflicts/testhelper_test.go +++ b/internal/gitaly/service/conflicts/testhelper_test.go @@ -54,7 +54,7 @@ func SetupConflictsService(t testing.TB, bare bool) (config.Cfg, *gitalypb.Repos var repoPath string var cleanup testhelper.Cleanup if bare { - repo, repoPath, cleanup = gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup = gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) } else { repo, repoPath, cleanup = gittest.CloneRepoWithWorktreeAtStorage(t, cfg, cfg.Storages[0]) diff --git a/internal/gitaly/service/hook/pre_receive_test.go b/internal/gitaly/service/hook/pre_receive_test.go index d534b6604..bf95a0fce 100644 --- a/internal/gitaly/service/hook/pre_receive_test.go +++ b/internal/gitaly/service/hook/pre_receive_test.go @@ -431,7 +431,7 @@ func TestPreReceiveHook_Primary(t *testing.T) { for i, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], fmt.Sprintf("repo-%d", i)) + testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], fmt.Sprintf("repo-%d", i)) defer cleanupFn() mux := http.NewServeMux() diff --git a/internal/gitaly/service/objectpool/alternates_test.go b/internal/gitaly/service/objectpool/alternates_test.go index a49b0408a..aafcfea4d 100644 --- a/internal/gitaly/service/objectpool/alternates_test.go +++ b/internal/gitaly/service/objectpool/alternates_test.go @@ -92,7 +92,7 @@ func TestDisconnectGitAlternatesUnexpectedAlternates(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) defer cleanupFn() altPath, err := locator.InfoAlternatesPath(repo) diff --git a/internal/gitaly/service/objectpool/link_test.go b/internal/gitaly/service/objectpool/link_test.go index 2e982fddc..816d67297 100644 --- a/internal/gitaly/service/objectpool/link_test.go +++ b/internal/gitaly/service/objectpool/link_test.go @@ -177,7 +177,7 @@ func TestUnlink(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - deletedRepo, deletedRepoPath, removeDeletedRepo := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "todelete") + deletedRepo, deletedRepoPath, removeDeletedRepo := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "todelete") defer removeDeletedRepo() gitCmdFactory := git.NewExecCommandFactory(cfg) diff --git a/internal/gitaly/service/operations/cherry_pick_test.go b/internal/gitaly/service/operations/cherry_pick_test.go index 60292ebb1..1f9d95987 100644 --- a/internal/gitaly/service/operations/cherry_pick_test.go +++ b/internal/gitaly/service/operations/cherry_pick_test.go @@ -31,7 +31,7 @@ func TestServer_UserCherryPick_successful(t *testing.T) { cherryPickedCommit, err := repo.ReadCommit(ctx, "8a0f2ee90d940bfb0ba1e14e8214b0649056e4ab") require.NoError(t, err) - testRepoCopy, testRepoCopyPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "read-only") // read-only repo + testRepoCopy, testRepoCopyPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "read-only") // read-only repo defer cleanup() gittest.Exec(t, cfg, "-C", testRepoCopyPath, "branch", destinationBranch, "master") diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go index b8c50a6a2..2c478881d 100644 --- a/internal/gitaly/service/operations/commit_files_test.go +++ b/internal/gitaly/service/operations/commit_files_test.go @@ -1116,7 +1116,7 @@ func TestSuccessfulUserCommitFilesRequestMove(t *testing.T) { {content: "foo", infer: true}, } { t.Run(strconv.Itoa(i), func(t *testing.T) { - testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) defer cleanupFn() origFileContent := gittest.Exec(t, cfg, "-C", testRepoPath, "show", branchName+":"+previousFilePath) diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go index 0989cec6c..02fa563df 100644 --- a/internal/gitaly/service/operations/rebase_test.go +++ b/internal/gitaly/service/operations/rebase_test.go @@ -44,7 +44,7 @@ func testSuccessfulUserRebaseConfirmableRequestFeatured(t *testing.T, ctx contex repo := localrepo.NewTestRepo(t, cfg, repoProto) - repoCopyProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + repoCopyProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") defer cleanup() branchSha := getBranchSha(t, cfg, repoPath, rebaseBranchName) @@ -267,7 +267,7 @@ func testFailedRebaseUserRebaseConfirmableRequestDueToInvalidHeader(t *testing.T func testFailedRebaseUserRebaseConfirmableRequestDueToInvalidHeaderFeatured(t *testing.T, ctx context.Context, cfg config.Cfg, rubySrv *rubyserver.Server) { ctx, cfg, repo, repoPath, client := setupOperationsServiceWithRuby(t, ctx, cfg, rubySrv) - repoCopy, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + repoCopy, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") defer cleanup() branchSha := getBranchSha(t, cfg, repoPath, rebaseBranchName) @@ -341,10 +341,10 @@ func testAbortedUserRebaseConfirmableFeatured(t *testing.T, ctx context.Context, for i, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - testRepo, testRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "repo") + testRepo, testRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "repo") defer cleanup() - testRepoCopy, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + testRepoCopy, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") defer cleanup() branchSha := getBranchSha(t, cfg, testRepoPath, rebaseBranchName) @@ -392,7 +392,7 @@ func testFailedUserRebaseConfirmableDueToApplyBeingFalseFeatured(t *testing.T, c repo := localrepo.NewTestRepo(t, cfg, repoProto) - testRepoCopy, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + testRepoCopy, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") defer cleanup() branchSha := getBranchSha(t, cfg, repoPath, rebaseBranchName) @@ -430,7 +430,7 @@ func testFailedUserRebaseConfirmableRequestDueToPreReceiveErrorFeatured(t *testi ctx, cfg, repoProto, repoPath, client := setupOperationsServiceWithRuby(t, ctx, cfg, rubySrv) repo := localrepo.NewTestRepo(t, cfg, repoProto) - repoCopyProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + repoCopyProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") defer cleanup() branchSha := getBranchSha(t, cfg, repoPath, rebaseBranchName) @@ -478,7 +478,7 @@ func testFailedUserRebaseConfirmableDueToGitError(t *testing.T, cfg config.Cfg, func testFailedUserRebaseConfirmableDueToGitErrorFeatured(t *testing.T, ctx context.Context, cfg config.Cfg, rubySrv *rubyserver.Server) { ctx, cfg, repoProto, repoPath, client := setupOperationsServiceWithRuby(t, ctx, cfg, rubySrv) - repoCopyProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + repoCopyProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") defer cleanup() failedBranchName := "rebase-encoding-failure-trigger" @@ -517,7 +517,7 @@ func testRebaseRequestWithDeletedFileFeatured(t *testing.T, ctx context.Context, repo := localrepo.NewTestRepo(t, cfg, repoProto) - repoCopyProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + repoCopyProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") defer cleanup() branch := "rebase-delete-test" diff --git a/internal/gitaly/service/operations/revert_test.go b/internal/gitaly/service/operations/revert_test.go index 9a2b54cb9..5784a0cb7 100644 --- a/internal/gitaly/service/operations/revert_test.go +++ b/internal/gitaly/service/operations/revert_test.go @@ -35,7 +35,7 @@ func testServerUserRevertSuccessfulFeatured(t *testing.T, ctx context.Context, c revertedCommit, err := repo.ReadCommit(ctx, "d59c60028b053793cecfb4022de34602e1a9218e") require.NoError(t, err) - testRepoCopy, testRepoCopyPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "read-only") // read-only repo + testRepoCopy, testRepoCopyPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "read-only") // read-only repo defer cleanup() gittest.Exec(t, cfg, "-C", testRepoCopyPath, "branch", destinationBranch, "master") diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go index 87b170dc0..f20d05c96 100644 --- a/internal/gitaly/service/operations/testhelper_test.go +++ b/internal/gitaly/service/operations/testhelper_test.go @@ -105,7 +105,7 @@ func setupOperationsService(t testing.TB, ctx context.Context) (context.Context, func setupOperationsServiceWithRuby( t testing.TB, ctx context.Context, cfg config.Cfg, rubySrv *rubyserver.Server, options ...testserver.GitalyServerOpt, ) (context.Context, config.Cfg, *gitalypb.Repository, string, gitalypb.OperationServiceClient) { - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) testhelper.ConfigureGitalySSHBin(t, cfg) diff --git a/internal/gitaly/service/operations/update_branches_test.go b/internal/gitaly/service/operations/update_branches_test.go index 6a5317210..cd86eba25 100644 --- a/internal/gitaly/service/operations/update_branches_test.go +++ b/internal/gitaly/service/operations/update_branches_test.go @@ -185,7 +185,7 @@ func testSuccessfulGitHooksForUserUpdateBranchRequestFeatured(t *testing.T, ctx for _, hookName := range GitlabHooks { t.Run(hookName, func(t *testing.T) { - testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "repo") + testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "repo") defer cleanupFn() hookOutputTempPath := gittest.WriteEnvToCustomHook(t, testRepoPath, hookName) diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go index b9f27f28c..2736e35fc 100644 --- a/internal/gitaly/service/ref/delete_refs_test.go +++ b/internal/gitaly/service/ref/delete_refs_test.go @@ -45,7 +45,7 @@ func TestSuccessfulDeleteRefs(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], testCase.desc) + repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], testCase.desc) defer cleanupFn() gittest.Exec(t, cfg, "-C", repoPath, "update-ref", "refs/delete/a", "b83d6e391c22777fca1ed3012fce84f633d7fed0") @@ -137,7 +137,7 @@ func TestDeleteRefs_transaction(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { votes = 0 - repo, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], tc.desc) + repo, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], tc.desc) t.Cleanup(cleanup) tc.request.Repository = repo diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go index 2854cd704..90e0af56d 100644 --- a/internal/gitaly/service/ref/testhelper_test.go +++ b/internal/gitaly/service/ref/testhelper_test.go @@ -46,7 +46,7 @@ func testMain(m *testing.M) int { func setupRefService(t testing.TB) (config.Cfg, *gitalypb.Repository, string, gitalypb.RefServiceClient) { cfg, client := setupRefServiceWithoutRepo(t) - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) testhelper.ConfigureGitalyHooksBin(t, cfg) diff --git a/internal/gitaly/service/remote/testhelper_test.go b/internal/gitaly/service/remote/testhelper_test.go index 82492835b..416c8ad0f 100644 --- a/internal/gitaly/service/remote/testhelper_test.go +++ b/internal/gitaly/service/remote/testhelper_test.go @@ -57,7 +57,7 @@ func TestWithRubySidecar(t *testing.T) { func setupRemoteServiceWithRuby(t *testing.T, cfg config.Cfg, rubySrv *rubyserver.Server) (config.Cfg, *gitalypb.Repository, string, gitalypb.RemoteServiceClient) { t.Helper() - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) addr := testserver.RunGitalyServer(t, cfg, rubySrv, func(srv *grpc.Server, deps *service.Dependencies) { diff --git a/internal/gitaly/service/remote/update_remote_mirror_test.go b/internal/gitaly/service/remote/update_remote_mirror_test.go index 9f02f964b..6266d60ef 100644 --- a/internal/gitaly/service/remote/update_remote_mirror_test.go +++ b/internal/gitaly/service/remote/update_remote_mirror_test.go @@ -480,10 +480,10 @@ func testSuccessfulUpdateRemoteMirrorRequestFeatured(t *testing.T, ctx context.C client, conn := newRemoteClient(t, serverSocketPath) defer conn.Close() - testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "source") + testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "source") defer cleanupFn() - _, mirrorPath, mirrorCleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "mirror") + _, mirrorPath, mirrorCleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "mirror") defer mirrorCleanupFn() remoteName := "remote_mirror_1" @@ -586,10 +586,10 @@ func testSuccessfulUpdateRemoteMirrorRequestWithWildcardsFeatured(t *testing.T, client, conn := newRemoteClient(t, serverSocketPath) defer conn.Close() - testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "source") + testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "source") defer cleanupFn() - _, mirrorPath, mirrorCleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "mirror") + _, mirrorPath, mirrorCleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "mirror") defer mirrorCleanupFn() remoteName := "remote_mirror_2" @@ -676,10 +676,10 @@ func testSuccessfulUpdateRemoteMirrorRequestWithKeepDivergentRefsFeatured(t *tes client, conn := newRemoteClient(t, serverSocketPath) defer conn.Close() - testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "source") + testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "source") defer cleanupFn() - _, mirrorPath, mirrorCleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "mirror") + _, mirrorPath, mirrorCleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "mirror") defer mirrorCleanupFn() remoteName := "remote_mirror_1" @@ -768,7 +768,7 @@ func testFailedUpdateRemoteMirrorRequestDueToValidationFeatured(t *testing.T, ct client, conn := newRemoteClient(t, serverSocketPath) defer conn.Close() - testRepo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + testRepo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) defer cleanupFn() testCases := []struct { diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go index 8d037f649..044dccd75 100644 --- a/internal/gitaly/service/repository/archive_test.go +++ b/internal/gitaly/service/repository/archive_test.go @@ -188,7 +188,7 @@ func TestGetArchiveWithLfsSuccess(t *testing.T) { serverSocketPath := runRepositoryServerWithConfig(t, cfg, nil) client := newRepositoryClient(t, cfg, serverSocketPath) - repo, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) testhelper.ConfigureGitalyLfsSmudge(t, cfg.BinDir) diff --git a/internal/gitaly/service/repository/cleanup_test.go b/internal/gitaly/service/repository/cleanup_test.go index a694faeb3..660da905b 100644 --- a/internal/gitaly/service/repository/cleanup_test.go +++ b/internal/gitaly/service/repository/cleanup_test.go @@ -77,7 +77,7 @@ func TestCleanupDeletesPackedRefsLock(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupFn) // Force the packed-refs file to have an old time to test that even @@ -142,7 +142,7 @@ func TestCleanupDeletesStaleWorktrees(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupFn) req := &gitalypb.CleanupRequest{Repository: repo} @@ -277,7 +277,7 @@ func TestCleanupDeletesPackedRefsNew(t *testing.T) { for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { - repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupFn) req := &gitalypb.CleanupRequest{Repository: repo} diff --git a/internal/gitaly/service/repository/config_test.go b/internal/gitaly/service/repository/config_test.go index f3307f926..284af9504 100644 --- a/internal/gitaly/service/repository/config_test.go +++ b/internal/gitaly/service/repository/config_test.go @@ -44,7 +44,7 @@ func TestDeleteConfig(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupFn) for _, k := range tc.addKeys { @@ -104,7 +104,7 @@ func testSetConfig(t *testing.T, cfg config.Cfg, rubySrv *rubyserver.Server) { ctx, cancel := testhelper.Context() defer cancel() - testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + testRepo, testRepoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) defer cleanupFn() _, err := client.SetConfig(ctx, &gitalypb.SetConfigRequest{Repository: testRepo, Entries: tc.entries}) diff --git a/internal/gitaly/service/repository/create_from_snapshot_test.go b/internal/gitaly/service/repository/create_from_snapshot_test.go index 1fbe64f40..219c2e61f 100644 --- a/internal/gitaly/service/repository/create_from_snapshot_test.go +++ b/internal/gitaly/service/repository/create_from_snapshot_test.go @@ -71,7 +71,7 @@ func createFromSnapshot(t *testing.T, req *gitalypb.CreateRepositoryFromSnapshot func TestCreateRepositoryFromSnapshotSuccess(t *testing.T) { cfg := testcfg.Build(t) - _, sourceRepoPath, cleanTestRepo := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + _, sourceRepoPath, cleanTestRepo := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanTestRepo) // Ensure these won't be in the archive @@ -116,7 +116,7 @@ func TestCreateRepositoryFromSnapshotSuccess(t *testing.T) { func TestCreateRepositoryFromSnapshotFailsIfRepositoryExists(t *testing.T) { cfg := testcfg.Build(t) - repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupFn) req := &gitalypb.CreateRepositoryFromSnapshotRequest{Repository: repo} @@ -128,7 +128,7 @@ func TestCreateRepositoryFromSnapshotFailsIfRepositoryExists(t *testing.T) { func TestCreateRepositoryFromSnapshotFailsIfBadURL(t *testing.T) { cfg := testcfg.Build(t) - repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) cleanupFn() // free up the destination dir for use req := &gitalypb.CreateRepositoryFromSnapshotRequest{ @@ -144,7 +144,7 @@ func TestCreateRepositoryFromSnapshotFailsIfBadURL(t *testing.T) { func TestCreateRepositoryFromSnapshotBadRequests(t *testing.T) { cfg := testcfg.Build(t) - repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) cleanupFn() // free up the destination dir for use testCases := []struct { @@ -199,7 +199,7 @@ func TestCreateRepositoryFromSnapshotBadRequests(t *testing.T) { func TestCreateRepositoryFromSnapshotHandlesMalformedResponse(t *testing.T) { cfg := testcfg.Build(t) - repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupFn) require.NoError(t, os.Remove(filepath.Join(repoPath, "config"))) diff --git a/internal/gitaly/service/repository/create_test.go b/internal/gitaly/service/repository/create_test.go index 677eb7781..2c916bea0 100644 --- a/internal/gitaly/service/repository/create_test.go +++ b/internal/gitaly/service/repository/create_test.go @@ -162,7 +162,7 @@ func TestCreateRepositoryTransactional(t *testing.T) { called = 0 actualVote = voting.Vote{} - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "clone.git") + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "clone.git") defer cleanup() _, err = client.CreateRepository(ctx, &gitalypb.CreateRepositoryRequest{ diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go index 174d3c217..3c6f2f202 100644 --- a/internal/gitaly/service/repository/fetch_remote_test.go +++ b/internal/gitaly/service/repository/fetch_remote_test.go @@ -687,7 +687,7 @@ func testFetchRemoteOverHTTP(t *testing.T, cfg config.Cfg, rubySrv *rubyserver.S for _, tc := range testCases { t.Run(tc.description, func(t *testing.T) { - forkedRepo, forkedRepoPath, forkedRepoCleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + forkedRepo, forkedRepoPath, forkedRepoCleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) defer forkedRepoCleanup() s, remoteURL := remoteHTTPServer(t, "my-repo", tc.httpToken) diff --git a/internal/gitaly/service/repository/fetch_test.go b/internal/gitaly/service/repository/fetch_test.go index 59138cccb..a8bf02c3e 100644 --- a/internal/gitaly/service/repository/fetch_test.go +++ b/internal/gitaly/service/repository/fetch_test.go @@ -21,7 +21,7 @@ func TestFetchSourceBranchSourceRepositorySuccess(t *testing.T) { md := testhelper.GitalyServersMetadataFromCfg(t, cfg) ctx = testhelper.MergeOutgoingMetadata(ctx, md) - targetRepoProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "fetch-source-target.git") + targetRepoProto, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "fetch-source-target.git") defer cleanup() targetRepo := localrepo.NewTestRepo(t, cfg, targetRepoProto) @@ -85,7 +85,7 @@ func TestFetchSourceBranchBranchNotFound(t *testing.T) { md := testhelper.GitalyServersMetadataFromCfg(t, cfg) ctx = testhelper.MergeOutgoingMetadata(ctx, md) - sourceRepo, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "fetch-source-source.git") + sourceRepo, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "fetch-source-source.git") t.Cleanup(cleanup) sourceBranch := "does-not-exist" @@ -133,7 +133,7 @@ func TestFetchSourceBranchWrongRef(t *testing.T) { md := testhelper.GitalyServersMetadataFromCfg(t, cfg) ctx = testhelper.MergeOutgoingMetadata(ctx, md) - sourceRepo, sourceRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "fetch-source-source.git") + sourceRepo, sourceRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "fetch-source-source.git") defer cleanup() sourceBranch := "fetch-source-branch-testmas-branch" diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go index 14c0ae593..4abcef8da 100644 --- a/internal/gitaly/service/repository/midx_test.go +++ b/internal/gitaly/service/repository/midx_test.go @@ -117,7 +117,7 @@ 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, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupFn) ctx, cancel := testhelper.Context() diff --git a/internal/gitaly/service/repository/rebase_in_progress_test.go b/internal/gitaly/service/repository/rebase_in_progress_test.go index c552392c2..bbdae6163 100644 --- a/internal/gitaly/service/repository/rebase_in_progress_test.go +++ b/internal/gitaly/service/repository/rebase_in_progress_test.go @@ -28,7 +28,7 @@ func TestSuccessfulIsRebaseInProgressRequest(t *testing.T) { gittest.Exec(t, cfg, "-C", repoPath1, "worktree", "add", "--detach", oldPath, "master") require.NoError(t, os.Chtimes(oldPath, time.Now(), time.Now().Add(-16*time.Minute))) - repo2, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "second") + repo2, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "second") t.Cleanup(cleanupFn) testCases := []struct { diff --git a/internal/gitaly/service/repository/rename_test.go b/internal/gitaly/service/repository/rename_test.go index cd280a50a..d920afa18 100644 --- a/internal/gitaly/service/repository/rename_test.go +++ b/internal/gitaly/service/repository/rename_test.go @@ -37,7 +37,7 @@ func TestRenameRepositorySuccess(t *testing.T) { func TestRenameRepositoryDestinationExists(t *testing.T) { cfg, repo, _, client := setupRepositoryService(t) - destinationRepo, destinationRepoPath, cleanupDestinationRepo := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "dst") + destinationRepo, destinationRepoPath, cleanupDestinationRepo := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "dst") t.Cleanup(cleanupDestinationRepo) sha := gittest.WriteCommit(t, cfg, destinationRepoPath) diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go index baf796f2e..84a61240e 100644 --- a/internal/gitaly/service/repository/replicate_test.go +++ b/internal/gitaly/service/repository/replicate_test.go @@ -34,7 +34,7 @@ func TestReplicateRepository(t *testing.T) { client := newRepositoryClient(t, cfg, serverSocketPath) - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "source") + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "source") t.Cleanup(cleanup) // create a loose object to ensure snapshot replication is used @@ -209,10 +209,10 @@ func TestReplicateRepository_BadRepository(t *testing.T) { client := newRepositoryClient(t, cfg, serverSocketPath) - sourceRepo, _, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "source") + sourceRepo, _, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "source") t.Cleanup(cleanup) - targetRepo, targetRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[1], sourceRepo.RelativePath) + targetRepo, targetRepoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[1], sourceRepo.RelativePath) t.Cleanup(cleanup) var invalidRepos []*gitalypb.Repository @@ -263,7 +263,7 @@ func TestReplicateRepository_FailedFetchInternalRemote(t *testing.T) { locator := config.NewLocator(cfg) - testRepo, _, cleanupRepo := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + testRepo, _, cleanupRepo := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupRepo) repoClient := newRepositoryClient(t, cfg, cfg.SocketPath) diff --git a/internal/gitaly/service/repository/repository_test.go b/internal/gitaly/service/repository/repository_test.go index b415f259b..003fc5576 100644 --- a/internal/gitaly/service/repository/repository_test.go +++ b/internal/gitaly/service/repository/repository_test.go @@ -23,7 +23,7 @@ func TestRepositoryExists(t *testing.T) { serverSocketPath := runRepositoryServerWithConfig(t, cfg, nil, testserver.WithDisablePraefect()) - repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanupFn) client := newRepositoryClient(t, cfg, serverSocketPath) diff --git a/internal/gitaly/service/repository/snapshot_test.go b/internal/gitaly/service/repository/snapshot_test.go index d7c5487cb..6b5910f9a 100644 --- a/internal/gitaly/service/repository/snapshot_test.go +++ b/internal/gitaly/service/repository/snapshot_test.go @@ -234,7 +234,7 @@ func copyRepoUsingSnapshot(t *testing.T, cfg config.Cfg, client gitalypb.Reposit srv := httptest.NewServer(&tarTesthandler{tarData: bytes.NewBuffer(data), secret: secret}) defer srv.Close() - repoCopy, repoCopyPath, cleanupCopy := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + repoCopy, repoCopyPath, cleanupCopy := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") // Delete the repository so we can re-use the path require.NoError(t, os.RemoveAll(repoCopyPath)) diff --git a/internal/gitaly/service/repository/squash_in_progress_test.go b/internal/gitaly/service/repository/squash_in_progress_test.go index e75079046..f7e10f49a 100644 --- a/internal/gitaly/service/repository/squash_in_progress_test.go +++ b/internal/gitaly/service/repository/squash_in_progress_test.go @@ -16,7 +16,7 @@ func TestSuccessfulIsSquashInProgressRequest(t *testing.T) { gittest.Exec(t, cfg, "-C", repoPath, "worktree", "add", "--detach", filepath.Join(repoPath, worktreePrefix, "squash-1"), "master") - repoCopy, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "copy") + repoCopy, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "copy") defer cleanupFn() testCases := []struct { diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go index a1960c51e..b196cbcaf 100644 --- a/internal/gitaly/service/repository/testhelper_test.go +++ b/internal/gitaly/service/repository/testhelper_test.go @@ -96,7 +96,7 @@ func setupRepositoryServiceWithRuby(t testing.TB, cfg config.Cfg, rubySrv *rubys client, serverSocketPath := runRepositoryService(t, cfg, rubySrv) cfg.SocketPath = serverSocketPath - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) return cfg, repo, repoPath, client @@ -167,7 +167,7 @@ func runRepositoryService(t testing.TB, cfg config.Cfg, rubySrv *rubyserver.Serv func setupRepositoryService(t testing.TB, opts ...testserver.GitalyServerOpt) (config.Cfg, *gitalypb.Repository, string, gitalypb.RepositoryServiceClient) { cfg, client := setupRepositoryServiceWithoutRepo(t, opts...) - repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, cleanup := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) t.Cleanup(cleanup) return cfg, repo, repoPath, client } diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go index b9486b1b0..7743ddfa6 100644 --- a/internal/gitaly/service/smarthttp/receive_pack_test.go +++ b/internal/gitaly/service/smarthttp/receive_pack_test.go @@ -627,7 +627,7 @@ func TestPostReceiveWithReferenceTransactionHook(t *testing.T) { stream, err := client.PostReceivePack(ctx) require.NoError(t, err) - repo, _, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, _, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) request := &gitalypb.PostReceivePackRequest{Repository: repo, GlId: "key-1234", GlRepository: "some_repo"} response := doPush(t, stream, request, newTestPush(t, cfg, nil).body) @@ -643,7 +643,7 @@ func TestPostReceiveWithReferenceTransactionHook(t *testing.T) { stream, err := client.PostReceivePack(ctx) require.NoError(t, err) - repo, repoPath, _ := gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + repo, repoPath, _ := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) // Create a new branch which we're about to delete. We also pack references because // this used to generate two transactions: one for the packed-refs file and one for diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go index 293d7d400..4a5081c1a 100644 --- a/internal/praefect/replicator_test.go +++ b/internal/praefect/replicator_test.go @@ -489,7 +489,7 @@ func TestConfirmReplication(t *testing.T) { cfg, testRepoA, testRepoAPath := testcfg.BuildWithRepo(t) srvSocketPath := testserver.RunGitalyServer(t, cfg, nil, setup.RegisterAll, testserver.WithDisablePraefect()) - testRepoB, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg.Storages[0], "second") + testRepoB, _, cleanupFn := gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], "second") t.Cleanup(cleanupFn) connOpts := []grpc.DialOption{ diff --git a/internal/praefect/service/info/consistencycheck_test.go b/internal/praefect/service/info/consistencycheck_test.go index 169adbd6f..5c16be716 100644 --- a/internal/praefect/service/info/consistencycheck_test.go +++ b/internal/praefect/service/info/consistencycheck_test.go @@ -57,8 +57,8 @@ func TestServer_ConsistencyCheck(t *testing.T) { targetCfg := testcfg.Build(t, testcfg.WithStorages(targetStorageName)) // firstRepoPath exists on both storages and has same state - gittest.CloneRepoAtStorage(t, referenceCfg.Storages[0], firstRepoPath) - gittest.CloneRepoAtStorage(t, targetCfg.Storages[0], firstRepoPath) + gittest.CloneRepoAtStorage(t, referenceCfg, referenceCfg.Storages[0], firstRepoPath) + gittest.CloneRepoAtStorage(t, targetCfg, targetCfg.Storages[0], firstRepoPath) referenceAddr := testserver.RunGitalyServer(t, referenceCfg, nil, setup.RegisterAll, testserver.WithDisablePraefect()) targetGitaly := testserver.StartGitalyServer(t, targetCfg, nil, setup.RegisterAll, testserver.WithDisablePraefect()) @@ -169,9 +169,9 @@ func TestServer_ConsistencyCheck(t *testing.T) { // secondRepoPath generates an error, but it should not stop other repositories from being processed. // Order does matter for the test to verify the flow. - gittest.CloneRepoAtStorage(t, referenceCfg.Storages[0], secondRepoPath) + gittest.CloneRepoAtStorage(t, referenceCfg, referenceCfg.Storages[0], secondRepoPath) // thirdRepoPath exists only on the reference storage (where traversal happens). - gittest.CloneRepoAtStorage(t, referenceCfg.Storages[0], thirdRepoPath) + gittest.CloneRepoAtStorage(t, referenceCfg, referenceCfg.Storages[0], thirdRepoPath) // not.git is a folder on the reference storage that should be skipped as it is not a git repository. require.NoError(t, os.MkdirAll(filepath.Join(referenceCfg.Storages[0].Path, "not.git"), os.ModePerm)) diff --git a/internal/tempdir/tempdir_test.go b/internal/tempdir/tempdir_test.go index 4342e724e..377482a3b 100644 --- a/internal/tempdir/tempdir_test.go +++ b/internal/tempdir/tempdir_test.go @@ -104,7 +104,7 @@ func TestCleanSuccess(t *testing.T) { func TestCleanTempDir(t *testing.T) { cfg := testcfg.Build(t, testcfg.WithStorages("first", "second")) - gittest.CloneRepoAtStorage(t, cfg.Storages[0], t.Name()) + gittest.CloneRepoAtStorage(t, cfg, cfg.Storages[0], t.Name()) logrus.SetLevel(logrus.InfoLevel) logrus.SetOutput(ioutil.Discard) |