From 93e2e4e88bbf54a1936cdb4dd3428dc949d72978 Mon Sep 17 00:00:00 2001 From: James Fargher Date: Fri, 7 Jul 2023 15:54:32 +1200 Subject: [PATCH] operations: Use HEAD for default in ApplyPatch The ApplyPatch RPC was using a default branch heuristic instead of directly using HEAD. --- .../gitaly/service/operations/apply_patch.go | 2 +- .../service/operations/apply_patch_test.go | 24 ------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/internal/gitaly/service/operations/apply_patch.go b/internal/gitaly/service/operations/apply_patch.go index 34cefcd2a6..7c96008d46 100644 --- a/internal/gitaly/service/operations/apply_patch.go +++ b/internal/gitaly/service/operations/apply_patch.go @@ -72,7 +72,7 @@ func (s *Server) userApplyPatch(ctx context.Context, header *gitalypb.UserApplyP return fmt.Errorf("resolve target branch: %w", err) } - defaultBranch, err := repo.GetDefaultBranch(ctx) + defaultBranch, err := repo.HeadReference(ctx) if err != nil { return fmt.Errorf("default branch name: %w", err) } diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go index b8dffa0146..bee4faa289 100644 --- a/internal/gitaly/service/operations/apply_patch_test.go +++ b/internal/gitaly/service/operations/apply_patch_test.go @@ -144,30 +144,6 @@ To restore the original branch and stop patching, run "git am --abort". } }, }, - { - desc: "creating a new branch from the first listed branch works", - baseTree: []gittest.TreeEntry{ - {Path: "file", Mode: "100644", Content: "base-content"}, - }, - baseReference: "refs/heads/a", - extraBranches: []string{"refs/heads/b"}, - targetBranch: "new-branch", - patches: []patchDescription{ - { - newTree: []gittest.TreeEntry{ - {Path: "file", Mode: "100644", Content: "patch 1"}, - }, - }, - }, - expected: func(t *testing.T, repoPath string) expected { - return expected{ - branchCreation: true, - tree: []gittest.TreeEntry{ - {Mode: "100644", Path: "file", Content: "patch 1"}, - }, - } - }, - }, { desc: "multiple patches apply cleanly", baseTree: []gittest.TreeEntry{ -- GitLab