diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/serializers/diff_file_entity.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/serializers/diff_file_entity.rb')
-rw-r--r-- | app/serializers/diff_file_entity.rb | 16 |
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 |