Skip to content

Add an option to use `unidiff` format for diff API responses

Vasilii Iakliushin requested to merge 23284_expose_unidiff_field_for_diffs into master

What does this MR do and why?

Contriubutes to #23284 (closed)

Problem

diff field doesn't return diff headers compatible with Unified format.

Solution

Use Unified format for diffs when unidiff option is provided. It should keep the backward compatibility with existing API.

Unified format: https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html

The current version of diff output is missing two headers:

--- a/test.yml
+++ b/test.yml

Screenshots or screen recordings

http://127.0.0.1:3000/api/v4/projects/1/repository/commits/HEAD/diff

image

http://127.0.0.1:3000/api/v4/projects/1/repository/commits/HEAD/diff?unidiff=true

Screenshot_2023-09-14_at_17.46.12

How to set up and validate locally

  1. Request diff for a commit in current diff format: http://127.0.0.1:3000/api/v4/projects/2/repository/commits/HEAD/diff
  2. Request diff for a commit in unidiff format: http://127.0.0.1:3000/api/v4/projects/2/repository/commits/HEAD/diff?unidiff=true

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Vasilii Iakliushin

Merge request reports

Loading