diff options
Diffstat (limited to 'lib/gitlab/diff/file_collection/base.rb')
-rw-r--r-- | lib/gitlab/diff/file_collection/base.rb | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb index 38b636e4e5a..cf0611e44da 100644 --- a/lib/gitlab/diff/file_collection/base.rb +++ b/lib/gitlab/diff/file_collection/base.rb @@ -60,12 +60,20 @@ module Gitlab end end - def diff_file_with_old_path(old_path) - diff_files.find { |diff_file| diff_file.old_path == old_path } + def diff_file_with_old_path(old_path, a_mode = nil) + if Feature.enabled?(:file_identifier_hash) && a_mode.present? + diff_files.find { |diff_file| diff_file.old_path == old_path && diff_file.a_mode == a_mode } + else + diff_files.find { |diff_file| diff_file.old_path == old_path } + end end - def diff_file_with_new_path(new_path) - diff_files.find { |diff_file| diff_file.new_path == new_path } + def diff_file_with_new_path(new_path, b_mode = nil) + if Feature.enabled?(:file_identifier_hash) && b_mode.present? + diff_files.find { |diff_file| diff_file.new_path == new_path && diff_file.b_mode == b_mode } + else + diff_files.find { |diff_file| diff_file.new_path == new_path } + end end def clear_cache @@ -80,15 +88,18 @@ module Gitlab def diff_stats_collection strong_memoize(:diff_stats) do - # There are scenarios where we don't need to request Diff Stats, - # when caching for instance. - next unless @include_stats - next unless diff_refs + next unless fetch_diff_stats? @repository.diff_stats(diff_refs.base_sha, diff_refs.head_sha) end end + def fetch_diff_stats? + # There are scenarios where we don't need to request Diff Stats, + # when caching for instance. + @include_stats && diff_refs + end + def decorate_diff!(diff) return diff if diff.is_a?(File) |