diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-12-04 11:15:19 -0200 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-12-04 13:13:22 -0200 |
commit | 89a676019cd580520e6c2ee696b15818d6ca954a (patch) | |
tree | 5013aeadf4db0913699ad87efe15159e82c3c5fc /lib | |
parent | e9e3820cf31eab7ea237a2c8bf24d370775c5a0b (diff) | |
download | gitlab-ce-89a676019cd580520e6c2ee696b15818d6ca954a.tar.gz |
Avoid 500's when serializing legacy diff notesosw-fix-grouping-by-file-path
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 |