summaryrefslogtreecommitdiff
path: root/app/serializers/diff_file_entity.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/diff_file_entity.rb')
-rw-r--r--app/serializers/diff_file_entity.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/serializers/diff_file_entity.rb b/app/serializers/diff_file_entity.rb
index e3fefbb46b6..9865af1e116 100644
--- a/app/serializers/diff_file_entity.rb
+++ b/app/serializers/diff_file_entity.rb
@@ -3,6 +3,7 @@
class DiffFileEntity < DiffFileBaseEntity
include CommitsHelper
include IconsHelper
+ include Gitlab::Utils::StrongMemoize
expose :added_lines
expose :removed_lines
@@ -54,11 +55,16 @@ class DiffFileEntity < DiffFileBaseEntity
# Used for inline diffs
expose :highlighted_diff_lines, using: DiffLineEntity, if: -> (diff_file, options) { inline_diff_view?(options, diff_file) && diff_file.text? } do |diff_file|
- diff_file.diff_lines_for_serializer
+ file = conflict_file(options, diff_file) || diff_file
+ file.diff_lines_for_serializer
end
expose :is_fully_expanded do |diff_file|
- diff_file.fully_expanded?
+ if conflict_file(options, diff_file)
+ false
+ else
+ diff_file.fully_expanded?
+ end
end
# Used for parallel diffs
@@ -79,4 +85,10 @@ class DiffFileEntity < DiffFileBaseEntity
# If nothing is present, inline will be the default.
options.fetch(:diff_view, :inline).to_sym == :inline
end
+
+ def conflict_file(options, diff_file)
+ strong_memoize(:conflict_file) do
+ options[:conflicts] && options[:conflicts][diff_file.new_path]
+ end
+ end
end