diff options
author | Sean McGivern <sean@gitlab.com> | 2018-01-30 18:17:44 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-01-30 18:17:44 +0300 |
commit | 382421a9bed1ef0fd1e97f6dcec8a104342ae1d8 (patch) | |
tree | 2be2a81e676fadc4d12e7e2a2e76e7433759da93 /app | |
parent | e74e6fcb5eecb7841a412cb0d3e9627556d83eaf (diff) |
Fix truncated_diff_lines for legacy notes without a line
It appears that some legacy diff notes on GitLab.com have invalid line codes,
which means truncated_diff_lines won't work. This is just a band-aid solution,
as neither the diff nor the discussion will display correctly for these notes,
but they won't cause a 500 error.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/discussion_on_diff.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/concerns/discussion_on_diff.rb b/app/models/concerns/discussion_on_diff.rb index db9770fabf4..8b3c55387b3 100644 --- a/app/models/concerns/discussion_on_diff.rb +++ b/app/models/concerns/discussion_on_diff.rb @@ -37,6 +37,8 @@ module DiscussionOnDiff # Returns an array of at most 16 highlighted lines above a diff note def truncated_diff_lines(highlight: true) + return [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote) + lines = highlight ? highlighted_diff_lines : diff_lines initial_line_index = [diff_line.index - NUMBER_OF_TRUNCATED_DIFF_LINES + 1, 0].max |