Skip to content

Highlight merge request conflicts displayed in diff

Igor Drozdov requested to merge id-highlight-diff-conflicts-backend into master

What does this MR do?

Related issue: #267337 (closed)

The idea is to highlight the conflicts in diff correctly. Currently, we have something like:

Or a live example: https://gitlab.com/igor.drozdov/wit-elixir/-/merge_requests/1/diffs?diff_head=true.

The idea is to have something like we have on Conflicts page:

In order to do this, we need to return particular types for diff lines for frontend if the line contains a conflict. This is the content of highlighted_diff_lines of diffs_batch.json:

0: {line_code: null, type: "match", old_line: null, new_line: null,…}
1: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_3_3", type: null, old_line: 3, new_line: 3,…}
2: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_4_4", type: null, old_line: 4, new_line: 4,…}
3: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_5_5", type: null, old_line: 5, new_line: 5,…}
4: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_6_6", type: "conflict_marker", old_line: 6,…}
5: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_6_7", type: "conflict_our", old_line: 6,…}
6: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_7_8", type: "conflict_our", old_line: 7,…}
7: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_8_9", type: "conflict_marker", old_line: 8,…}
8: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_8_10", type: "conflict_their", old_line: 8,…}
9: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_8_11", type: "conflict_their", old_line: 8,…}
10: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_8_12", type: "conflict_marker", old_line: 8,…}
11: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_8_13", type: null, old_line: 8, new_line: 13,…}
12: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_9_14", type: null, old_line: 9, new_line: 14,…}
13: {line_code: "5ad7e407cf4219f3e31929ec34b3716c69c308e3_10_15", type: null, old_line: 10, new_line: 15,…}

our lines have conflict_our type, their lines have conflict_their type and markers (>>>>>>>, <<<<<<<<, =======) have conflict_marker type

Edited by Igor Drozdov

Merge request reports