Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-01-30 18:17:44 +0300
committerSean McGivern <sean@gitlab.com>2018-01-30 18:17:44 +0300
commit382421a9bed1ef0fd1e97f6dcec8a104342ae1d8 (patch)
tree2be2a81e676fadc4d12e7e2a2e76e7433759da93 /app/models/concerns/discussion_on_diff.rb
parente74e6fcb5eecb7841a412cb0d3e9627556d83eaf (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/models/concerns/discussion_on_diff.rb')
-rw-r--r--app/models/concerns/discussion_on_diff.rb2
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