Expose conflict sections on MergeRequest.conflictFiles
What does this MR do and why?
Adds a sections field to MergeRequest.conflictFiles (Types::MergeRequests::ConflictType). It mirrors the conflicts UI's JSON: each conflicting file's content split into sections, where a section is a run of lines that is either one conflict to resolve or context shared by both sides.
MergeRequestConflictSection:conflict(boolean),lines, andsectionId(null for context sections). The field is namedsectionIdrather thanidbecauseTypes::BaseObject#idwould try to build a GraphQL global ID out of the section hash.MergeRequestConflictLine:type(CONTEXT,HEAD,ORIGIN,MATCH,NO_NEWLINE),oldLine,newLine,text.
Without this field, an API client that wants to resolve a conflict section by section, rather than by sending a whole file's resolved content, would have to re-implement GitLab's conflict parser and line numbering just to compute section ids. With this field the ids are opaque values the server hands out, and the client only has to echo them back.
This field and the mergeRequestResolveConflicts mutation (!256558 (closed)) are both 19.5 experiments. The mutation takes these ids as sectionId in its input.
References
- Split off !256558 (closed) at the reviewer's request: !256558 (comment 3884155756)
- Answers !256558 (comment 3878108665): where does an API client get the section ids from.
Screenshots or screen recordings
Not applicable. GraphQL-only change, no UI.
How to set up and validate locally
-
Create a merge request whose branches conflict (the spec fixture branches
conflict-resolvableintoconflict-startin the test repository work for this). -
Query the new field:
{ project(fullPath: "group/project") { mergeRequest(iid: "1") { conflictFiles { ourPath theirPath sections { sectionId conflict lines { type oldLine newLine text } } } } } } -
Each conflict section has a
sectionId; context sections havesectionId: null.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
- Specs:
spec/graphql/types/merge_requests/conflict_type_spec.rb,spec/graphql/types/merge_requests/conflict_section_type_spec.rb,spec/graphql/types/merge_requests/conflict_line_type_spec.rb,spec/graphql/types/merge_requests/conflict_line_type_enum_spec.rb,spec/requests/api/graphql/merge_request/conflict_files_spec.rb. - Generated: GraphQL reference docs (
doc/api/graphql/reference/_index.md), introspection schemas. - Experiment, milestone 19.5, additive and read-only, so no feature flag.