Add an option to use `unidiff` format for diff API responses
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
http://127.0.0.1:3000/api/v4/projects/1/repository/commits/HEAD/diff?unidiff=true
How to set up and validate locally
- Request diff for a commit in current diff format: http://127.0.0.1:3000/api/v4/projects/2/repository/commits/HEAD/diff
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Vasilii Iakliushin