diff options
author | Karthik Nayak <knayak@gitlab.com> | 2023-07-12 18:46:44 +0300 |
---|---|---|
committer | Karthik Nayak <knayak@gitlab.com> | 2023-07-13 12:46:15 +0300 |
commit | df26ba544c6b86ff299b378eb5ad71223795e63d (patch) | |
tree | 81bcff7549f4835ba214380b117a5237b37587ba | |
parent | 69b92ae88c34e961c97eac81cd13b197fd23c066 (diff) |
conflicts: Implement `SkipContentParsing` in `ListConflictFiles`
In the previous commit, we introduced the new field `SkipContentParsing`
in the proto definition of `ListConflictFilesRequest`. The field will be
used to skip conflicted file's content parsing and streaming.
Let's implement the usage of the field by simply skipping the content
parsing and streaming section within the `ListConflictFiles` RPC. Also
add a test to test for this new functionality.
-rw-r--r-- | internal/gitaly/service/conflicts/list_conflict_files.go | 5 | ||||
-rw-r--r-- | internal/gitaly/service/conflicts/list_conflict_files_test.go | 46 |
2 files changed, 51 insertions, 0 deletions
diff --git a/internal/gitaly/service/conflicts/list_conflict_files.go b/internal/gitaly/service/conflicts/list_conflict_files.go index 8ee05a132..d5f62a810 100644 --- a/internal/gitaly/service/conflicts/list_conflict_files.go +++ b/internal/gitaly/service/conflicts/list_conflict_files.go @@ -127,6 +127,11 @@ func (s *server) conflictFilesWithGitMergeTree( }, }) + // Clients do not want the contents of the conflicted files, so we skip this section. + if request.GetSkipContent() { + continue + } + path := conflict.ourPath if path == "" { path = conflict.theirPath diff --git a/internal/gitaly/service/conflicts/list_conflict_files_test.go b/internal/gitaly/service/conflicts/list_conflict_files_test.go index ccfbd4adb..04b5725c5 100644 --- a/internal/gitaly/service/conflicts/list_conflict_files_test.go +++ b/internal/gitaly/service/conflicts/list_conflict_files_test.go @@ -85,6 +85,52 @@ func TestListConflictFiles(t *testing.T) { }, }, { + "Lists the expected conflict files without content", + func(tb testing.TB, ctx context.Context) setupData { + cfg, client := setupConflictsService(tb, nil) + repo, repoPath := gittest.CreateRepository(tb, ctx, cfg) + + ourCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( + gittest.TreeEntry{Path: "a", Mode: "100644", Content: "apple"}, + gittest.TreeEntry{Path: "b", Mode: "100644", Content: "banana"}, + )) + theirCommitID := gittest.WriteCommit(tb, cfg, repoPath, gittest.WithTreeEntries( + gittest.TreeEntry{Path: "a", Mode: "100644", Content: "mango"}, + gittest.TreeEntry{Path: "b", Mode: "100644", Content: "peach"}, + )) + + request := &gitalypb.ListConflictFilesRequest{ + Repository: repo, + OurCommitOid: ourCommitID.String(), + TheirCommitOid: theirCommitID.String(), + SkipContent: true, + } + + return setupData{ + client: client, + request: request, + expectedFiles: []*conflictFile{ + { + Header: &gitalypb.ConflictFileHeader{ + CommitOid: ourCommitID.String(), + TheirPath: []byte("a"), + OurPath: []byte("a"), + OurMode: int32(0o100644), + }, + }, + { + Header: &gitalypb.ConflictFileHeader{ + CommitOid: ourCommitID.String(), + TheirPath: []byte("b"), + OurPath: []byte("b"), + OurMode: int32(0o100644), + }, + }, + }, + } + }, + }, + { "Lists the expected conflict files with short OIDs", func(tb testing.TB, ctx context.Context) setupData { cfg, client := setupConflictsService(tb, nil) |