diff options
author | Nick Thomas <nick@gitlab.com> | 2018-12-05 16:40:24 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-12-05 16:40:24 +0300 |
commit | 61bc233ef0df1395ad82ec8d48ee4dfd8c67e0be (patch) | |
tree | b01607cdff4a3d15d010a67b5ea375e1078a55bc /lib | |
parent | da2da0fa599f0a27d0f00e4b2077f7940cf935df (diff) | |
parent | 89a676019cd580520e6c2ee696b15818d6ca954a (diff) |
Merge branch 'osw-fix-grouping-by-file-path' into 'master'
Avoid 500's when serializing legacy diff notes
Closes #54793
See merge request gitlab-org/gitlab-ce!23544
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/diff/file_collection/base.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/diff/file_collection/compare.rb | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb index 10df037a0dd..c5bbf522f7c 100644 --- a/lib/gitlab/diff/file_collection/base.rb +++ b/lib/gitlab/diff/file_collection/base.rb @@ -34,6 +34,16 @@ module Gitlab @diff_files ||= diffs.decorate! { |diff| decorate_diff!(diff) } end + # This mutates `diff_files` lines. + def unfold_diff_files(positions) + positions_grouped_by_path = positions.group_by { |position| position.file_path } + + diff_files.each do |diff_file| + positions = positions_grouped_by_path.fetch(diff_file.file_path, []) + positions.each { |position| diff_file.unfold_diff_lines(position) } + end + end + def diff_file_with_old_path(old_path) diff_files.find { |diff_file| diff_file.old_path == old_path } end diff --git a/lib/gitlab/diff/file_collection/compare.rb b/lib/gitlab/diff/file_collection/compare.rb index 586c5cf87af..663bad95db7 100644 --- a/lib/gitlab/diff/file_collection/compare.rb +++ b/lib/gitlab/diff/file_collection/compare.rb @@ -10,6 +10,10 @@ module Gitlab diff_options: diff_options, diff_refs: diff_refs) end + + def unfold_diff_lines(positions) + # no-op + end end end end |