diff options
author | John Cai <johncai86@gmail.com> | 2022-12-28 21:29:27 +0300 |
---|---|---|
committer | John Cai <johncai86@gmail.com> | 2022-12-28 21:29:27 +0300 |
commit | d3c8c181b1cbe18c6d8f5bd157a35793123e0343 (patch) | |
tree | a532e04b351380097319f4c3d611ba6bd3b83e5c | |
parent | 434f838ce706807c757103541de508ad29c0b9f3 (diff) |
fixing operations tests
-rw-r--r-- | internal/gitaly/service/operations/apply_patch_test.go | 45 | ||||
-rw-r--r-- | internal/gitaly/service/operations/branches_test.go | 47 | ||||
-rw-r--r-- | internal/gitaly/service/operations/cherry_pick_test.go | 36 | ||||
-rw-r--r-- | internal/gitaly/service/operations/commit_files_test.go | 1 | ||||
-rw-r--r-- | internal/gitaly/service/operations/merge_test.go | 112 | ||||
-rw-r--r-- | internal/gitaly/service/operations/rebase_test.go | 80 | ||||
-rw-r--r-- | internal/gitaly/service/operations/revert_test.go | 30 | ||||
-rw-r--r-- | internal/gitaly/service/operations/squash_test.go | 106 | ||||
-rw-r--r-- | internal/gitaly/service/operations/tags_test.go | 65 |
9 files changed, 279 insertions, 243 deletions
diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go index 6f4ed3cc3..51bcf1597 100644 --- a/internal/gitaly/service/operations/apply_patch_test.go +++ b/internal/gitaly/service/operations/apply_patch_test.go @@ -67,7 +67,7 @@ To restore the original branch and stop patching, run "git am --abort". // targetBranch is the branch where the patched commit goes. targetBranch string // expectedOldOID is a function which provides the expectedOldOID given the repoPath. - expectedOldOID func(repoPath string) string + expectedOldOID func(repo *localrepo.Repo) string // extraBranches are created with empty commits for verifying the correct base branch // gets selected. extraBranches []string @@ -321,7 +321,10 @@ To restore the original branch and stop patching, run "git am --abort". expectedTree: []git.TreeEntry{ {Mode: "100644", Path: "file", Content: "patch 1"}, }, - expectedOldOID: func(repoPath string) string { + expectedOldOID: func(repo *localrepo.Repo) string { + repoPath, err := repo.Path() + require.NoError(t, err) + return text.ChompBytes(git.Exec(t, cfg, "-C", repoPath, "rev-parse", "master")) }, }, @@ -339,7 +342,7 @@ To restore the original branch and stop patching, run "git am --abort". }, }, }, - expectedOldOID: func(repoPath string) string { return "foo" }, + expectedOldOID: func(repo *localrepo.Repo) string { return "foo" }, expectedErr: structerr.NewInternal(`expected old object id not expected SHA format: invalid object ID: "foo"`), }, { @@ -356,8 +359,10 @@ To restore the original branch and stop patching, run "git am --abort". }, }, }, - expectedOldOID: func(repoPath string) string { return git.DefaultObjectHash.ZeroOID.String() }, - expectedErr: structerr.NewInternal("expected old object cannot be resolved: reference not found"), + expectedOldOID: func(repo *localrepo.Repo) string { + return git.DefaultObjectHash.ZeroOID.String() + }, + expectedErr: structerr.NewInternal("expected old object cannot be resolved: reference not found"), }, { desc: "existing branch + expectedOldOID set to an old commit OID", @@ -373,11 +378,14 @@ To restore the original branch and stop patching, run "git am --abort". }, }, }, - expectedOldOID: func(repoPath string) string { + expectedOldOID: func(repo *localrepo.Repo) string { + repoPath, err := repo.Path() + require.NoError(t, err) + currentCommit := text.ChompBytes(git.Exec(t, cfg, "-C", repoPath, "rev-parse", "master")) // add a new commit to master so we can point at the old one, this is // because by default the test only creates one commit - WriteTestCommit(t, git, cfg, repoPath, git.WithParents(git.ObjectID(currentCommit)), git.WithBranch("master")) + localrepo.WriteTestCommit(t, repo, localrepo.WithParents(git.ObjectID(currentCommit)), localrepo.WithBranch("master")) return currentCommit }, expectedErr: structerr.NewInternal(`update reference: Could not update refs/heads/master. Please refresh and try again.`), @@ -397,14 +405,13 @@ To restore the original branch and stop patching, run "git am --abort". var baseCommit git.ObjectID if tc.baseTree != nil { - baseCommit = WriteTestCommit(t, git, cfg, repoPath, - git.WithTreeEntries(tc.baseTree...), - git.WithReference(string(tc.baseReference))) - + baseCommit = localrepo.WriteTestCommit(t, repo, + localrepo.WithTreeEntries(tc.baseTree...), + localrepo.WithReference(string(tc.baseReference))) } if tc.extraBranches != nil { - emptyCommit := WriteTestCommit(t, git, cfg, repoPath) + emptyCommit := localrepo.WriteTestCommit(t, repo) for _, extraBranch := range tc.extraBranches { git.WriteRef(t, cfg, repoPath, git.NewReferenceNameFromBranchName(extraBranch), emptyCommit) } @@ -415,15 +422,15 @@ To restore the original branch and stop patching, run "git am --abort". oldCommit := baseCommit if patch.oldTree != nil { - oldCommit = WriteTestCommit(t, git, cfg, repoPath, - git.WithTreeEntries(patch.oldTree...)) + oldCommit = localrepo.WriteTestCommit(t, repo, + localrepo.WithTreeEntries(patch.oldTree...)) } - newCommit := git.WriteTestCommit(t, cfg, repoPath, - git.WithMessage(commitMessage), - git.WithTreeEntries(patch.newTree...), - git.WithParents(oldCommit), + newCommit := localrepo.WriteTestCommit(t, repo, + localrepo.WithMessage(commitMessage), + localrepo.WithTreeEntries(patch.newTree...), + localrepo.WithParents(oldCommit), ) formatPatchArgs := []string{"-C", repoPath, "format-patch", "--stdout"} @@ -452,7 +459,7 @@ To restore the original branch and stop patching, run "git am --abort". expectedOldOID := "" if tc.expectedOldOID != nil { - expectedOldOID = tc.expectedOldOID(repoPath) + expectedOldOID = tc.expectedOldOID(repo) } require.NoError(t, stream.Send(&gitalypb.UserApplyPatchRequest{ diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go index b6d07dc6f..06342aa9c 100644 --- a/internal/gitaly/service/operations/branches_test.go +++ b/internal/gitaly/service/operations/branches_test.go @@ -440,9 +440,10 @@ func TestUserDeleteBranch(t *testing.T) { desc: "simple successful deletion without ExpectedOldOID", setup: func() setupResponse { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo) + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithParents(firstCommit)) git.Exec(t, cfg, "-C", repoPath, "branch", "to-attempt-to-delete-soon-branch", "master") @@ -462,9 +463,10 @@ func TestUserDeleteBranch(t *testing.T) { desc: "simple successful deletion with ExpectedOldOID", setup: func() setupResponse { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath) - headCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo) + headCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithParents(firstCommit)) git.Exec(t, cfg, "-C", repoPath, "branch", "to-attempt-to-delete-soon-branch", "master") @@ -487,9 +489,10 @@ func TestUserDeleteBranch(t *testing.T) { branchName := "heads/to-attempt-to-delete-soon-branch" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo) + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithParents(firstCommit)) git.Exec(t, cfg, "-C", repoPath, "branch", branchName, "master") @@ -511,9 +514,10 @@ func TestUserDeleteBranch(t *testing.T) { branchName := "refs/heads/branch" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo) + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithParents(firstCommit)) git.Exec(t, cfg, "-C", repoPath, "branch", branchName, "master") @@ -535,9 +539,10 @@ func TestUserDeleteBranch(t *testing.T) { branchName := "random-branch" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo) + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithParents(firstCommit)) git.Exec(t, cfg, "-C", repoPath, "branch", branchName, "master") @@ -560,9 +565,10 @@ func TestUserDeleteBranch(t *testing.T) { branchName := "random-branch" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo) + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithParents(firstCommit)) git.Exec(t, cfg, "-C", repoPath, "branch", branchName, "master") @@ -585,9 +591,10 @@ func TestUserDeleteBranch(t *testing.T) { branchName := "random-branch" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo) + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithParents(firstCommit)) git.Exec(t, cfg, "-C", repoPath, "branch", branchName, "master") @@ -697,11 +704,13 @@ func TestUserDeleteBranch_allowed(t *testing.T) { gitlab.NewMockClient(t, tc.allowed, gitlab.MockPreReceive, gitlab.MockPostReceive), )) - repo, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("branch")) + repoProto, _ := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) + + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("branch")) response, err := client.UserDeleteBranch(ctx, &gitalypb.UserDeleteBranchRequest{ - Repository: repo, + Repository: repoProto, BranchName: []byte("branch"), User: git.TestUser, }) @@ -716,9 +725,9 @@ func TestUserDeleteBranch_concurrentUpdate(t *testing.T) { ctx := testhelper.Context(t) - ctx, cfg, repo, repoPath, client := setupOperationsService(t, ctx) + ctx, cfg, repo, _, client := setupOperationsService(t, ctx) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("concurrent-update")) + commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo), localrepo.WithBranch("concurrent-update")) // Create a git-update-ref(1) process that's locking the "concurrent-update" branch. We do // not commit the update yet though to keep the reference locked to simulate concurrent diff --git a/internal/gitaly/service/operations/cherry_pick_test.go b/internal/gitaly/service/operations/cherry_pick_test.go index b07961ef1..26a605ccc 100644 --- a/internal/gitaly/service/operations/cherry_pick_test.go +++ b/internal/gitaly/service/operations/cherry_pick_test.go @@ -227,10 +227,10 @@ func TestUserCherryPick(t *testing.T) { setup: func(data setupData) (*gitalypb.UserCherryPickRequest, *gitalypb.UserCherryPickResponse) { git.Exec(t, data.cfg, "-C", data.repoPath, "branch", destinationBranch, "master") - git.WriteTestCommit(t, data.cfg, data.repoPath, - git.WithParents(git.ObjectID(data.masterCommit)), - git.WithBranch("master"), - git.WithTreeEntries( + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, data.cfg, data.repoProto), + localrepo.WithParents(git.ObjectID(data.masterCommit)), + localrepo.WithBranch("master"), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, ), ) @@ -255,37 +255,39 @@ func TestUserCherryPick(t *testing.T) { t.Parallel() repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - masterCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), - git.WithTreeEntries( + repo := localrepo.NewTestRepo(t, cfg, repoProto) + + masterCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, )) - cherryPickCommitID := WriteTestCommit(t, git, cfg, repoPath, - git.WithParents(masterCommitID), - git.WithTreeEntries( + cherryPickCommitID := localrepo.WriteTestCommit(t, repo, + localrepo.WithParents(masterCommitID), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, git.TreeEntry{Mode: "100644", Path: "foo", Content: "bar"}, )) - repo := localrepo.NewTestRepo(t, cfg, repoProto) cherryPickedCommit, err := repo.ReadCommit(ctx, cherryPickCommitID.Revision()) require.NoError(t, err) copyRepoProto, copyRepoPath := git.CreateRepository(t, ctx, cfg) - masterCommitCopyID := WriteTestCommit(t, git, cfg, copyRepoPath, git.WithBranch("master"), - git.WithTreeEntries( + copyRepo := localrepo.NewTestRepo(t, cfg, copyRepoProto) + + masterCommitCopyID := localrepo.WriteTestCommit(t, copyRepo, localrepo.WithBranch("master"), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, )) - cherryPickCommitCopyID := WriteTestCommit(t, git, cfg, copyRepoPath, - git.WithParents(masterCommitCopyID), - git.WithTreeEntries( + cherryPickCommitCopyID := localrepo.WriteTestCommit(t, copyRepo, + localrepo.WithParents(masterCommitCopyID), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, git.TreeEntry{Mode: "100644", Path: "foo", Content: "bar"}, )) - copyRepo := localrepo.NewTestRepo(t, cfg, repoProto) - copyCherryPickedCommit, err := copyRepo.ReadCommit(ctx, cherryPickCommitCopyID.Revision()) + copyCherryPickedCommit, err := repo.ReadCommit(ctx, cherryPickCommitCopyID.Revision()) require.NoError(t, err) req, expectedResp := tc.setup(setupData{ diff --git a/internal/gitaly/service/operations/commit_files_test.go b/internal/gitaly/service/operations/commit_files_test.go index 518364660..cdb6fae34 100644 --- a/internal/gitaly/service/operations/commit_files_test.go +++ b/internal/gitaly/service/operations/commit_files_test.go @@ -45,6 +45,7 @@ func testUserCommitFiles(t *testing.T, ctx context.Context) { ExecutableMode = "100755" ) + startRepo, _ := git.CreateRepository(t, ctx, cfg) targetRepoSentinel := &gitalypb.Repository{} type step struct { diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go index ffe7bfbca..aea3b6a17 100644 --- a/internal/gitaly/service/operations/merge_test.go +++ b/internal/gitaly/service/operations/merge_test.go @@ -159,10 +159,10 @@ func TestUserMergeBranch(t *testing.T) { desc: "incorrect expectedOldOID", hooks: []string{}, setup: func(data setupData) setupResponse { - git.WriteTestCommit(t, cfg, data.repoPath, - git.WithParents(git.ObjectID(data.masterCommit)), - git.WithBranch(data.branch), - git.WithTreeEntries( + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, data.repoProto), + localrepo.WithParents(git.ObjectID(data.masterCommit)), + localrepo.WithBranch(data.branch), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, git.TreeEntry{Mode: "100644", Path: "b", Content: "banana"}, ), @@ -207,15 +207,16 @@ func TestUserMergeBranch(t *testing.T) { message := "Merged by Gitaly" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - masterCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(branchToMerge), - git.WithTreeEntries( + masterCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(branchToMerge), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, )) - mergeCommitID := WriteTestCommit(t, git, cfg, repoPath, - git.WithParents(masterCommitID), - git.WithTreeEntries( + mergeCommitID := localrepo.WriteTestCommit(t, repo, + localrepo.WithParents(masterCommitID), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, git.TreeEntry{Mode: "100644", Path: "foo", Content: "bar"}, )) @@ -279,7 +280,6 @@ func TestUserMergeBranch(t *testing.T) { _, err = mergeBidi.Recv() require.Equal(t, io.EOF, err) - repo := localrepo.NewTestRepo(t, cfg, repoProto) commit, err := repo.ReadCommit(ctx, git.Revision(branchToMerge)) require.NoError(t, err, "look up git commit after call has finished") @@ -310,21 +310,22 @@ func TestUserMergeBranch_failure(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repoProto, _ := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - master := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithTreeEntries( + master := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "a", Content: "apple"}, )) - commit1 := WriteTestCommit(t, git, cfg, repoPath, git.WithTreeEntries( + commit1 := localrepo.WriteTestCommit(t, repo, localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "b", Content: "banana"}, )) branchToMerge := "branchToMerge" - git.WriteTestCommit(t, cfg, repoPath, - git.WithBranch(branchToMerge), - git.WithParents(commit1), - git.WithTreeEntries( + localrepo.WriteTestCommit(t, repo, + localrepo.WithBranch(branchToMerge), + localrepo.WithParents(commit1), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "b", Content: "banana"}, ), ) @@ -676,8 +677,8 @@ func TestUserMergeBranch_concurrentUpdate(t *testing.T) { require.NoError(t, err, "receive first response") // This concurrent update of the branch we are merging into should make the merge fail. - concurrentCommitID := WriteTestCommit(t, git, cfg, repoPath, - git.WithBranch(mergeBranchName)) + concurrentCommitID := localrepo.WriteTestCommit(t, repo, + localrepo.WithBranch(mergeBranchName)) require.NotEqual(t, firstResponse.CommitId, concurrentCommitID) @@ -861,22 +862,23 @@ func TestUserMergeBranch_conflict(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, repoProto, repoPath, client := setupOperationsService(t, ctx) + repo := localrepo.NewTestRepo(t, cfg, repoProto) const mergeIntoBranch = "mergeIntoBranch" const mergeFromBranch = "mergeFromBranch" const conflictingFile = "file" - baseCommit := git.WriteCommit(t, cfg, repoPath, git.WithBranch(mergeIntoBranch), git.WithTreeEntries(git.TreeEntry{ + baseCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(mergeIntoBranch), localrepo.WithTreeEntries(git.TreeEntry{ Mode: "100644", Path: conflictingFile, Content: "data", })) git.Exec(t, cfg, "-C", repoPath, "branch", mergeFromBranch, baseCommit.String()) - divergedInto := git.WriteCommit(t, cfg, repoPath, git.WithBranch(mergeIntoBranch), git.WithTreeEntries(git.TreeEntry{ + divergedInto := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(mergeIntoBranch), localrepo.WithTreeEntries(git.TreeEntry{ Mode: "100644", Path: conflictingFile, Content: "data-1", })) - divergedFrom := git.WriteCommit(t, cfg, repoPath, git.WithBranch(mergeFromBranch), git.WithTreeEntries(git.TreeEntry{ + divergedFrom := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(mergeFromBranch), localrepo.WithTreeEntries(git.TreeEntry{ Mode: "100644", Path: conflictingFile, Content: "data-2", })) @@ -1052,9 +1054,10 @@ func TestUserFFBranch(t *testing.T) { desc: "successful", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1077,9 +1080,10 @@ func TestUserFFBranch(t *testing.T) { desc: "successful + expectedOldOID", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1102,10 +1106,11 @@ func TestUserFFBranch(t *testing.T) { { desc: "empty repository", setup: func(t *testing.T, ctx context.Context) setupData { - _, repoPath := git.CreateRepository(t, ctx, cfg) + repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1122,9 +1127,10 @@ func TestUserFFBranch(t *testing.T) { desc: "empty user", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1141,9 +1147,10 @@ func TestUserFFBranch(t *testing.T) { desc: "empty commit", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1160,9 +1167,10 @@ func TestUserFFBranch(t *testing.T) { desc: "non-existing commit", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1180,9 +1188,10 @@ func TestUserFFBranch(t *testing.T) { desc: "empty branch", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1199,9 +1208,10 @@ func TestUserFFBranch(t *testing.T) { desc: "non-existing branch", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1219,9 +1229,10 @@ func TestUserFFBranch(t *testing.T) { desc: "commit is not a descendant of branch head", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithTreeEntries( + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithTreeEntries( git.TreeEntry{Path: "file", Mode: "100644", Content: "something"}, )) @@ -1241,9 +1252,10 @@ func TestUserFFBranch(t *testing.T) { desc: "invalid expectedOldOID", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1262,9 +1274,10 @@ func TestUserFFBranch(t *testing.T) { desc: "valid SHA, but not existing expectedOldOID", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master")) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit)) + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master")) + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit)) return setupData{ repoPath: repoPath, @@ -1283,17 +1296,18 @@ func TestUserFFBranch(t *testing.T) { desc: "expectedOldOID pointing to old commit", setup: func(t *testing.T, ctx context.Context) setupData { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - firstCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithTreeEntries( + firstCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithTreeEntries( git.TreeEntry{Path: "bar", Mode: "100644", Content: "something"}, )) - secondCommit := git.WriteTestCommit(t, cfg, repoPath, git.WithBranch("master"), git.WithParents(firstCommit), - git.WithTreeEntries( + secondCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithParents(firstCommit), + localrepo.WithTreeEntries( git.TreeEntry{Path: "foo", Mode: "100644", Content: "something"}, ), ) - commitToMerge := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(secondCommit), git.WithTreeEntries( + commitToMerge := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(secondCommit), localrepo.WithTreeEntries( git.TreeEntry{Path: "goo", Mode: "100644", Content: "something"}, )) diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go index d18a5e3e8..cf3a38baa 100644 --- a/internal/gitaly/service/operations/rebase_test.go +++ b/internal/gitaly/service/operations/rebase_test.go @@ -91,41 +91,42 @@ func TestUserRebaseConfirmable_skipEmptyCommits(t *testing.T) { ctx := testhelper.Context(t) - ctx, cfg, repoProto, repoPath, client := setupOperationsService(t, ctx) + ctx, cfg, repoProto, _, client := setupOperationsService(t, ctx) + repo := localrepo.NewTestRepo(t, cfg, repoProto) // This is the base commit from which both "theirs" and "ours" branch from". - baseCommit := WriteTestCommit(t, git, cfg, repoPath, - git.WithTreeEntries( + baseCommit := localrepo.WriteTestCommit(t, repo, + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "README", Content: "a\nb\nc\nd\ne\nf\n"}, )) // "theirs" changes the first line of the file to contain a "1". - theirs := git.WriteTestCommit(t, cfg, repoPath, - git.WithParents(baseCommit), - git.WithTreeEntries( + theirs := localrepo.WriteTestCommit(t, repo, + localrepo.WithParents(baseCommit), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "README", Content: "1\nb\nc\nd\ne\nf\n"}, ), - git.WithMessage("theirs"), - git.WithBranch("theirs"), + localrepo.WithMessage("theirs"), + localrepo.WithBranch("theirs"), ) // We create two commits on "ours": the first one does the same changes as "theirs", but // with a different commit ID. It is expected to become empty. And the second commit is an // independent change which modifies the last line. - oursBecomingEmpty := git.WriteTestCommit(t, cfg, repoPath, - git.WithParents(baseCommit), - git.WithTreeEntries( + oursBecomingEmpty := localrepo.WriteTestCommit(t, repo, + localrepo.WithParents(baseCommit), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "README", Content: "1\nb\nc\nd\ne\nf\n"}, ), - git.WithMessage("ours but same change as theirs"), + localrepo.WithMessage("ours but same change as theirs"), ) - ours := git.WriteTestCommit(t, cfg, repoPath, - git.WithParents(oursBecomingEmpty), - git.WithTreeEntries( + ours := localrepo.WriteTestCommit(t, repo, + localrepo.WithParents(oursBecomingEmpty), + localrepo.WithTreeEntries( git.TreeEntry{Mode: "100644", Path: "README", Content: "1\nb\nc\nd\ne\n6\n"}, ), - git.WithMessage("ours with additional changes"), - git.WithBranch("ours"), + localrepo.WithMessage("ours with additional changes"), + localrepo.WithBranch("ours"), ) stream, err := client.UserRebaseConfirmable(ctx) @@ -631,13 +632,14 @@ func TestUserRebaseConfirmable_deletedFileInLocalRepo(t *testing.T) { localRepoProto, localRepoPath := git.CreateRepository(t, ctx, cfg) localRepo := localrepo.NewTestRepo(t, cfg, localRepoProto) - remoteRepoProto, remoteRepoPath := git.CreateRepository(t, ctx, cfg) + remoteRepoProto, _ := git.CreateRepository(t, ctx, cfg) + remoteRepo := localrepo.NewTestRepo(t, cfg, remoteRepoProto) // Write the root commit into both repositories as common history. var rootCommitID git.ObjectID - for _, path := range []string{localRepoPath, remoteRepoPath} { - rootCommitID = WriteTestCommit(t, git, cfg, path, - git.WithTreeEntries( + for _, repo := range []*localrepo.Repo{localRepo, remoteRepo} { + rootCommitID = localrepo.WriteTestCommit(t, repo, + localrepo.WithTreeEntries( git.TreeEntry{Path: "change-me", Mode: "100644", Content: "unchanged contents"}, git.TreeEntry{Path: "delete-me", Mode: "100644", Content: "useless stuff"}, )) @@ -645,22 +647,22 @@ func TestUserRebaseConfirmable_deletedFileInLocalRepo(t *testing.T) { } // Write a commit into the local repository that deletes a single file. - localCommitID := git.WriteTestCommit(t, cfg, localRepoPath, - git.WithParents(rootCommitID), - git.WithTreeEntries( + localCommitID := localrepo.WriteTestCommit(t, localRepo, + localrepo.WithParents(rootCommitID), + localrepo.WithTreeEntries( git.TreeEntry{Path: "change-me", Mode: "100644", Content: "unchanged contents"}, ), - git.WithBranch("local"), + localrepo.WithBranch("local"), ) // And then finally write a commit into the remote repository that changes a different file. - git.WriteTestCommit(t, cfg, remoteRepoPath, - git.WithParents(rootCommitID), - git.WithTreeEntries( + localrepo.WriteTestCommit(t, remoteRepo, + localrepo.WithParents(rootCommitID), + localrepo.WithTreeEntries( git.TreeEntry{Path: "change-me", Mode: "100644", Content: "modified contents"}, git.TreeEntry{Path: "delete-me", Mode: "100644", Content: "useless stuff"}, ), - git.WithBranch("remote"), + localrepo.WithBranch("remote"), ) // Send the first request to tell the server to perform the rebase. @@ -701,27 +703,27 @@ func TestUserRebaseConfirmable_deletedFileInRemoteRepo(t *testing.T) { localRepoProto, localRepoPath := git.CreateRepository(t, ctx, cfg) localRepo := localrepo.NewTestRepo(t, cfg, localRepoProto) - remoteRepoProto, remoteRepoPath := git.CreateRepository(t, ctx, cfg) + remoteRepoProto, _ := git.CreateRepository(t, ctx, cfg) + remoteRepo := localrepo.NewTestRepo(t, cfg, remoteRepoProto) // Write the root commit into both repositories as common history. var rootCommitID git.ObjectID - for _, path := range []string{localRepoPath, remoteRepoPath} { - rootCommitID = WriteTestCommit(t, git, cfg, path, - git.WithTreeEntries( + for _, repo := range []*localrepo.Repo{localRepo, remoteRepo} { + rootCommitID = localrepo.WriteTestCommit(t, repo, + localrepo.WithTreeEntries( git.TreeEntry{Path: "unchanged", Mode: "100644", Content: "unchanged contents"}, git.TreeEntry{Path: "delete-me", Mode: "100644", Content: "useless stuff"}, ), - git.WithBranch("local")) - + localrepo.WithBranch("local")) } // Write a commit into the remote repository that deletes a file. - remoteCommitID := git.WriteTestCommit(t, cfg, remoteRepoPath, - git.WithParents(rootCommitID), - git.WithTreeEntries( + remoteCommitID := localrepo.WriteTestCommit(t, remoteRepo, + localrepo.WithParents(rootCommitID), + localrepo.WithTreeEntries( git.TreeEntry{Path: "unchanged", Mode: "100644", Content: "unchanged contents"}, ), - git.WithBranch("remote"), + localrepo.WithBranch("remote"), ) _, err := localRepo.ReadCommit(ctx, remoteCommitID.Revision()) diff --git a/internal/gitaly/service/operations/revert_test.go b/internal/gitaly/service/operations/revert_test.go index 3a243d4d9..5fa35858b 100644 --- a/internal/gitaly/service/operations/revert_test.go +++ b/internal/gitaly/service/operations/revert_test.go @@ -40,7 +40,7 @@ func TestUserRevert(t *testing.T) { { desc: "successful", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(branchName), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(branchName), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -64,7 +64,7 @@ func TestUserRevert(t *testing.T) { { desc: "nonexistent branch + start_repository == repository", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -91,10 +91,10 @@ func TestUserRevert(t *testing.T) { { desc: "nonexistent branch + start_repository != repository", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - startRepoProto, startRepoPath := git.CreateRepository(t, ctx, cfg) + startRepoProto, _ := git.CreateRepository(t, ctx, cfg) startRepo := localrepo.NewTestRepo(t, cfg, startRepoProto) - firstCommitID := WriteTestCommit(t, git, cfg, startRepoPath, git.WithBranch("master"), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, startRepo, localrepo.WithBranch("master"), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -120,7 +120,7 @@ func TestUserRevert(t *testing.T) { { desc: "successful with dry run", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(branchName), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(branchName), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -146,7 +146,7 @@ func TestUserRevert(t *testing.T) { { desc: "nonexistent branch + start_repository == repository with dry run", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("master"), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("master"), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -175,10 +175,10 @@ func TestUserRevert(t *testing.T) { { desc: "nonexistent branch + start_repository != repository with dry run", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - startRepoProto, startRepoPath := git.CreateRepository(t, ctx, cfg) + startRepoProto, _ := git.CreateRepository(t, ctx, cfg) startRepo := localrepo.NewTestRepo(t, cfg, startRepoProto) - firstCommitID := WriteTestCommit(t, git, cfg, startRepoPath, git.WithBranch("master"), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, startRepo, localrepo.WithBranch("master"), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -244,7 +244,7 @@ func TestUserRevert(t *testing.T) { { desc: "empty branch name", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(branchName), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(branchName), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -265,7 +265,7 @@ func TestUserRevert(t *testing.T) { { desc: "empty message", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(branchName), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(branchName), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -286,7 +286,7 @@ func TestUserRevert(t *testing.T) { { desc: "successful + expectedOldOID", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(branchName), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(branchName), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -311,7 +311,7 @@ func TestUserRevert(t *testing.T) { { desc: "successful + invalid expectedOldOID", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(branchName), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(branchName), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -334,7 +334,7 @@ func TestUserRevert(t *testing.T) { { desc: "expectedOldOID with valid SHA, but not present in repo", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithBranch(branchName), git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithBranch(branchName), localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "foobar"}, )) @@ -357,11 +357,11 @@ func TestUserRevert(t *testing.T) { { desc: "expectedOldOID pointing to old commit", setup: func(t *testing.T, repoPath string, repoProto *gitalypb.Repository, repo *localrepo.Repo) setupData { - firstCommitID := WriteTestCommit(t, git, cfg, repoPath, git.WithTreeEntries( + firstCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithTreeEntries( git.TreeEntry{Path: "blob", Mode: "100644", Content: "bar"}, )) - secondCommitID := git.WriteTestCommit(t, cfg, repoPath, git.WithParents(firstCommitID), git.WithBranch(branchName), git.WithTreeEntries( + secondCommitID := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommitID), localrepo.WithBranch(branchName), localrepo.WithTreeEntries( git.TreeEntry{Path: "bolb", Mode: "100644", Content: "foo"}, )) secondCommit, err := repo.ReadCommit(ctx, secondCommitID.Revision()) diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go index f6ceb6695..40783c742 100644 --- a/internal/gitaly/service/operations/squash_test.go +++ b/internal/gitaly/service/operations/squash_test.go @@ -327,34 +327,33 @@ func TestUserSquash_renames(t *testing.T) { ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main")) - repo := localrepo.NewTestRepo(t, cfg, repoProto) + localrepo.WriteTestCommit(t, repo, localrepo.WithBranch("main")) + originalFilename := "original-file.txt" renamedFilename := "renamed-file.txt" - rootCommitID := WriteTestCommit(t, git, cfg, repoPath, - git.WithTreeEntries( + rootCommitID := localrepo.WriteTestCommit(t, repo, + localrepo.WithTreeEntries( git.TreeEntry{Path: originalFilename, Mode: "100644", Content: "This is a test"}, )) - startCommitID := WriteTestCommit(t, git, cfg, repoPath, - git.WithParents(rootCommitID), - git.WithTreeEntries( + startCommitID := localrepo.WriteTestCommit(t, repo, + localrepo.WithParents(rootCommitID), + localrepo.WithTreeEntries( git.TreeEntry{Path: renamedFilename, Mode: "100644", Content: "This is a test"}, )) - changedCommitID := WriteTestCommit(t, git, cfg, repoPath, - git.WithParents(rootCommitID), - git.WithTreeEntries( + changedCommitID := localrepo.WriteTestCommit(t, repo, + localrepo.WithParents(rootCommitID), + localrepo.WithTreeEntries( git.TreeEntry{Path: originalFilename, Mode: "100644", Content: "This is a change"}, )) - endCommitID := WriteTestCommit(t, git, cfg, repoPath, - git.WithParents(changedCommitID), - git.WithTreeEntries( + endCommitID := localrepo.WriteTestCommit(t, repo, + localrepo.WithParents(changedCommitID), + localrepo.WithTreeEntries( git.TreeEntry{Path: originalFilename, Mode: "100644", Content: "This is another change"}, )) @@ -416,23 +415,23 @@ func TestUserSquash_emptyCommit(t *testing.T) { // Set up history with two diverging lines of branches, where both sides have implemented // the same changes. During merge, the diff will thus become empty. - base := WriteTestCommit(t, git, cfg, repoPath, - git.WithTreeEntries( + base := localrepo.WriteTestCommit(t, repo, + localrepo.WithTreeEntries( git.TreeEntry{Path: "a", Content: "base", Mode: "100644"}, )) - theirs := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("theirs"), - git.WithParents(base), git.WithTreeEntries( + theirs := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("theirs"), + localrepo.WithParents(base), localrepo.WithTreeEntries( git.TreeEntry{Path: "a", Content: "changed", Mode: "100644"}, ), ) - ours := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("ours"), - git.WithParents(base), git.WithTreeEntries( + ours := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("ours"), + localrepo.WithParents(base), localrepo.WithTreeEntries( git.TreeEntry{Path: "a", Content: "changed", Mode: "100644"}, ), ) - oursWithAdditionalChanges := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("ours"), - git.WithParents(ours), git.WithTreeEntries( + oursWithAdditionalChanges := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("ours"), + localrepo.WithParents(ours), localrepo.WithTreeEntries( git.TreeEntry{Path: "a", Content: "changed", Mode: "100644"}, git.TreeEntry{Path: "ours", Content: "ours", Mode: "100644"}, ), @@ -612,25 +611,26 @@ func TestUserSquash_conflicts(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - ctx, cfg, repo, repoPath, client := setupOperationsService(t, ctx) + ctx, cfg, repoProto, _, client := setupOperationsService(t, ctx) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - base := WriteTestCommit(t, git, cfg, repoPath, git.WithTreeEntries( + base := localrepo.WriteTestCommit(t, repo, localrepo.WithTreeEntries( git.TreeEntry{Path: "a", Mode: "100644", Content: "unchanged"}, git.TreeEntry{Path: "b", Mode: "100644", Content: "base"}, )) - ours := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(base), git.WithTreeEntries( + ours := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(base), localrepo.WithTreeEntries( git.TreeEntry{Path: "a", Mode: "100644", Content: "unchanged"}, git.TreeEntry{Path: "b", Mode: "100644", Content: "ours"}, )) - theirs := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(base), git.WithTreeEntries( + theirs := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(base), localrepo.WithTreeEntries( git.TreeEntry{Path: "a", Mode: "100644", Content: "unchanged"}, git.TreeEntry{Path: "b", Mode: "100644", Content: "theirs"}, )) response, err := client.UserSquash(ctx, &gitalypb.UserSquashRequest{ - Repository: repo, + Repository: repoProto, User: git.TestUser, Author: git.TestUser, CommitMessage: commitMessage, @@ -660,22 +660,23 @@ func TestUserSquash_ancestry(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - ctx, cfg, repo, repoPath, client := setupOperationsService(t, ctx) + ctx, cfg, repoProto, _, client := setupOperationsService(t, ctx) + repo := localrepo.NewTestRepo(t, cfg, repoProto) // We create an empty parent commit and two commits which both branch off from it. As a // result, they are not direct ancestors of each other. - parent := WriteTestCommit(t, git, cfg, repoPath, git.WithMessage("p"), git.WithTreeEntries()) - commit1 := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("1"), - git.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "a-content"}), - git.WithParents(parent), + parent := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("p"), localrepo.WithTreeEntries()) + commit1 := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("1"), + localrepo.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "a-content"}), + localrepo.WithParents(parent), ) - commit2 := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("2"), - git.WithTreeEntries(git.TreeEntry{Path: "b", Mode: "100644", Content: "b-content"}), - git.WithParents(parent), + commit2 := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("2"), + localrepo.WithTreeEntries(git.TreeEntry{Path: "b", Mode: "100644", Content: "b-content"}), + localrepo.WithParents(parent), ) response, err := client.UserSquash(ctx, &gitalypb.UserSquashRequest{ - Repository: repo, + Repository: repoProto, User: git.TestUser, Author: git.TestUser, CommitMessage: commitMessage, @@ -795,29 +796,30 @@ func TestUserSquash_squashingMerge(t *testing.T) { t.Parallel() ctx := testhelper.Context(t) - ctx, cfg, repo, repoPath, client := setupOperationsService(t, ctx) + ctx, cfg, repoProto, repoPath, client := setupOperationsService(t, ctx) + repo := localrepo.NewTestRepo(t, cfg, repoProto) - base := WriteTestCommit(t, git, cfg, repoPath, git.WithMessage("base"), - git.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "base-content"})) + base := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("base"), + localrepo.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "base-content"})) - ours := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("ours"), - git.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "ours-content"}), - git.WithParents(base), + ours := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("ours"), + localrepo.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "ours-content"}), + localrepo.WithParents(base), ) - theirs := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("theirs"), - git.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "theirs-content"}), - git.WithParents(base), + theirs := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("theirs"), + localrepo.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "theirs-content"}), + localrepo.WithParents(base), ) - oursMergedIntoTheirs := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("merge ours into theirs"), - git.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "ours-content\ntheirs-content"}), - git.WithParents(theirs, ours), + oursMergedIntoTheirs := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("merge ours into theirs"), + localrepo.WithTreeEntries(git.TreeEntry{Path: "a", Mode: "100644", Content: "ours-content\ntheirs-content"}), + localrepo.WithParents(theirs, ours), ) - ours2 := git.WriteTestCommit(t, cfg, repoPath, git.WithMessage("ours 2"), - git.WithTreeEntries( + ours2 := localrepo.WriteTestCommit(t, repo, localrepo.WithMessage("ours 2"), + localrepo.WithTreeEntries( git.TreeEntry{Path: "a", Mode: "100644", Content: "ours-content"}, git.TreeEntry{Path: "ours-file", Mode: "100644", Content: "new-content"}, ), - git.WithParents(ours), + localrepo.WithParents(ours), ) // We had conflicting commit on "ours" and on "theirs", @@ -832,7 +834,7 @@ func TestUserSquash_squashingMerge(t *testing.T) { // // We're now squashing both commits from "theirs" onto "ours". response, err := client.UserSquash(ctx, &gitalypb.UserSquashRequest{ - Repository: repo, + Repository: repoProto, User: git.TestUser, Author: git.TestUser, CommitMessage: commitMessage, diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go index a81d2fa66..e60b84be1 100644 --- a/internal/gitaly/service/operations/tags_test.go +++ b/internal/gitaly/service/operations/tags_test.go @@ -45,7 +45,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "mercury" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithReference("refs/tags/"+tagName)) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -60,7 +60,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "venus" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - commit := WriteTestCommit(t, git, cfg, repoPath, git.WithReference("refs/tags/"+tagName)) + commit := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -76,7 +76,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "refs/tags/earth" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithReference("refs/tags/"+tagName)) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -90,8 +90,8 @@ func TestUserDeleteTag(t *testing.T) { desc: "no repository provided", setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "mars" - _, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath) + repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto)) return repoPath, &gitalypb.UserDeleteTagRequest{ TagName: []byte(tagName), @@ -105,7 +105,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "jupiter" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -118,7 +118,7 @@ func TestUserDeleteTag(t *testing.T) { desc: "empty tag name", setup: func() (string, *gitalypb.UserDeleteTagRequest) { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -132,7 +132,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "uranus" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithReference("refs/tags/"+tagName)) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -148,7 +148,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "sun" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithReference("refs/tags/"+tagName)) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -164,7 +164,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "moon" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithReference("refs/tags/"+tagName)) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -180,7 +180,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "europa" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithReference("refs/tags/"+tagName)) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -197,7 +197,7 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "europa" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithReference("refs/tags/"+tagName)) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repoProto), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -214,8 +214,9 @@ func TestUserDeleteTag(t *testing.T) { setup: func() (string, *gitalypb.UserDeleteTagRequest) { tagName := "ganymede" repoProto, repoPath := git.CreateRepository(t, ctx, cfg) - firstCommit := WriteTestCommit(t, git, cfg, repoPath) - WriteTestCommit(t, git, cfg, repoPath, git.WithParents(firstCommit), git.WithReference("refs/tags/"+tagName)) + repo := localrepo.NewTestRepo(t, cfg, repoProto) + firstCommit := localrepo.WriteTestCommit(t, repo) + localrepo.WriteTestCommit(t, repo, localrepo.WithParents(firstCommit), localrepo.WithReference("refs/tags/"+tagName)) return repoPath, &gitalypb.UserDeleteTagRequest{ Repository: repoProto, @@ -330,7 +331,7 @@ func TestUserCreateTag_successful(t *testing.T) { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, repo, localrepo.WithParents()) targetRevisionCommit, err := repo.ReadCommit(ctx, commitID.Revision()) require.NoError(t, err) @@ -468,7 +469,7 @@ func TestUserCreateTag_transactional(t *testing.T) { ) } - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, repo, localrepo.WithParents()) targetCommit, err := repo.ReadCommit(ctx, commitID.Revision()) require.NoError(t, err) @@ -523,7 +524,7 @@ func TestUserCreateTag_quarantine(t *testing.T) { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, repo, localrepo.WithParents()) tagIDOutputPath := filepath.Join(testhelper.TempDir(t), "tag-id") @@ -640,7 +641,7 @@ func TestUserCreateTag_message(t *testing.T) { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, repo, localrepo.WithParents()) commit, err := repo.ReadCommit(ctx, commitID.Revision()) require.NoError(t, err) @@ -735,16 +736,16 @@ func TestUserCreateTag_targetRevision(t *testing.T) { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) - baseCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(), git.WithMessage("1")) + baseCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(), localrepo.WithMessage("1")) // We create an ambiguous branching structure that has "refs/heads/main", // "refs/heads/heads/main" and "refs/heads/refs/heads/main" to exercise how // we resolve the tag's target revision. - git.WriteTestCommit(t, cfg, repoPath, git.WithParents(baseCommit), git.WithBranch("main"), git.WithMessage("2")) - git.WriteTestCommit(t, cfg, repoPath, git.WithParents(baseCommit), git.WithBranch("heads/main"), git.WithMessage("3")) - git.WriteTestCommit(t, cfg, repoPath, git.WithParents(baseCommit), git.WithBranch("refs/heads/main"), git.WithMessage("4")) + localrepo.WriteTestCommit(t, repo, localrepo.WithParents(baseCommit), localrepo.WithBranch("main"), localrepo.WithMessage("2")) + localrepo.WriteTestCommit(t, repo, localrepo.WithParents(baseCommit), localrepo.WithBranch("heads/main"), localrepo.WithMessage("3")) + localrepo.WriteTestCommit(t, repo, localrepo.WithParents(baseCommit), localrepo.WithBranch("refs/heads/main"), localrepo.WithMessage("4")) - taggedCommit := WriteTestCommit(t, git, cfg, repoPath, git.WithParents(baseCommit), git.WithMessage("5")) + taggedCommit := localrepo.WriteTestCommit(t, repo, localrepo.WithParents(baseCommit), localrepo.WithMessage("5")) git.WriteTag(t, cfg, repoPath, "v1.0.0", taggedCommit.Revision()) expectedCommit, err := repo.ReadCommit(ctx, git.Revision(tc.expectedRevision)) @@ -990,10 +991,10 @@ func TestUserCreateTag_stableTagIDs(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repoProto, repoPath := git.CreateRepository(t, ctx, cfg) + repoProto, _ := git.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, repo, localrepo.WithParents()) commit, err := repo.ReadCommit(ctx, commitID.Revision()) require.NoError(t, err) @@ -1025,7 +1026,7 @@ func TestUserCreateTag_prefixedTag(t *testing.T) { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, repo, localrepo.WithParents()) commit, err := repo.ReadCommit(ctx, commitID.Revision()) require.NoError(t, err) @@ -1063,7 +1064,7 @@ func TestUserCreateTag_gitHooks(t *testing.T) { repoProto, repoPath := git.CreateRepository(t, ctx, cfg) repo := localrepo.NewTestRepo(t, cfg, repoProto) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, repo, localrepo.WithParents()) commit, err := repo.ReadCommit(ctx, commitID.Revision()) require.NoError(t, err) @@ -1144,7 +1145,7 @@ func TestUserCreateTag_hookFailure(t *testing.T) { } { t.Run(tc.hook, func(t *testing.T) { repo, repoPath := git.CreateRepository(t, ctx, cfg) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo), localrepo.WithParents()) git.WriteCustomHook(t, repoPath, tc.hook, []byte( "#!/bin/sh\necho GL_ID=$GL_ID\nexit 1"), @@ -1180,7 +1181,7 @@ func TestUserCreateTag_preexisting(t *testing.T) { ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) repo, repoPath := git.CreateRepository(t, ctx, cfg) - commitID := WriteTestCommit(t, git, cfg, repoPath, git.WithParents()) + commitID := localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo), localrepo.WithParents()) git.WriteTag(t, cfg, repoPath, "v1.1.0", commitID.Revision()) for _, tc := range []struct { @@ -1234,8 +1235,8 @@ func TestUserCreateTag_invalidArgument(t *testing.T) { ctx := testhelper.Context(t) ctx, cfg, client := setupOperationsServiceWithoutRepo(t, ctx) - repo, repoPath := git.CreateRepository(t, ctx, cfg) - WriteTestCommit(t, git, cfg, repoPath, git.WithBranch("main"), git.WithParents()) + repo, _ := git.CreateRepository(t, ctx, cfg) + localrepo.WriteTestCommit(t, localrepo.NewTestRepo(t, cfg, repo), localrepo.WithBranch("main"), localrepo.WithParents()) injectedTag := "inject-tag\ntagger . <> 0 +0000\n\nInjected subject\n\n" @@ -1266,8 +1267,6 @@ func TestUserCreateTag_invalidArgument(t *testing.T) { targetRevision: "", user: git.TestUser, expectedErr: structerr.NewInvalidArgument("validating request: empty target revision"), - user: git.TestUser, - expectedErr: structerr.NewInvalidArgument("validating request: empty target revision"), }, { desc: "non-existing starting point", |