diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-12-07 17:24:37 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-12-07 17:24:37 +0300 |
commit | 7385e7cd47f1eaab355d2fd8ca91b9d056b4576d (patch) | |
tree | 25f35ba7b6ff972cca7ebe66a932d7ac3fe40890 /app/models/concerns/discussion_on_diff.rb | |
parent | 61d91f640b94d6e273dee502b77e723b599ab86c (diff) |
Backports changes made to One notification per code review
The EE merge request can be found here:
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8442
Diffstat (limited to 'app/models/concerns/discussion_on_diff.rb')
-rw-r--r-- | app/models/concerns/discussion_on_diff.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/concerns/discussion_on_diff.rb b/app/models/concerns/discussion_on_diff.rb index c180d7b7c9a..266c37fa3a1 100644 --- a/app/models/concerns/discussion_on_diff.rb +++ b/app/models/concerns/discussion_on_diff.rb @@ -38,12 +38,13 @@ module DiscussionOnDiff end # Returns an array of at most 16 highlighted lines above a diff note - def truncated_diff_lines(highlight: true) + def truncated_diff_lines(highlight: true, diff_limit: nil) return [] if diff_line.nil? && first_note.is_a?(LegacyDiffNote) + diff_limit = [diff_limit, NUMBER_OF_TRUNCATED_DIFF_LINES].compact.min lines = highlight ? highlighted_diff_lines : diff_lines - initial_line_index = [diff_line.index - NUMBER_OF_TRUNCATED_DIFF_LINES + 1, 0].max + initial_line_index = [diff_line.index - diff_limit + 1, 0].max prev_lines = [] |