Skip to content
Snippets Groups Projects

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

Merged Vasilii Iakliushin requested to merge 23284_expose_unidiff_field_for_diffs into master
All threads resolved!
Files
3
+ 3
3
@@ -187,10 +187,10 @@ def unidiff
return diff if diff.blank?
return json_safe_diff if detect_binary?(@diff) || has_binary_notice?
return "--- /dev/null\n+++ b/#{new_path}\n" + diff if new_file?
return "--- a/#{old_path}\n+++ /dev/null\n" + diff if deleted_file?
old_path_header = new_file? ? '/dev/null' : "a/#{old_path}"
new_path_header = deleted_file? ? '/dev/null' : "b/#{new_path}"
"--- a/#{old_path}\n+++ b/#{new_path}\n" + diff
"--- #{old_path_header}\n+++ #{new_path_header}\n" + diff
end
def line_count
Loading