summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/discussion.rb12
-rw-r--r--app/views/discussions/_diff_with_notes.html.haml2
-rw-r--r--app/views/notify/_note_mr_or_commit_email.html.haml9
-rw-r--r--app/views/notify/_simple_diff.text.erb4
-rw-r--r--app/views/notify/note_commit_email.html.haml6
-rw-r--r--app/views/notify/note_commit_email.text.erb2
-rw-r--r--app/views/notify/note_merge_request_email.html.haml6
-rw-r--r--app/views/notify/note_merge_request_email.text.erb2
8 files changed, 25 insertions, 18 deletions
diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index de06c13481a..486bfd2c766 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -25,7 +25,12 @@ class Discussion
to: :last_resolved_note,
allow_nil: true
- delegate :blob, :highlighted_diff_lines, to: :diff_file, allow_nil: true
+ delegate :blob,
+ :highlighted_diff_lines,
+ :text_parsed_diff_lines,
+
+ to: :diff_file,
+ allow_nil: true
def self.for_notes(notes)
notes.group_by(&:discussion_id).values.map { |notes| new(notes) }
@@ -162,18 +167,15 @@ class Discussion
def truncated_diff_lines
prev_lines = []
- highlighted_diff_lines.each do |line|
+ diff_file.diff_lines.each do |line|
if line.meta?
prev_lines.clear
else
prev_lines << line
-
break if for_line?(line)
-
prev_lines.shift if prev_lines.length >= NUMBER_OF_TRUNCATED_DIFF_LINES
end
end
-
prev_lines
end
diff --git a/app/views/discussions/_diff_with_notes.html.haml b/app/views/discussions/_diff_with_notes.html.haml
index 3a95a652810..06493ba0105 100644
--- a/app/views/discussions/_diff_with_notes.html.haml
+++ b/app/views/discussions/_diff_with_notes.html.haml
@@ -9,7 +9,7 @@
%table
- discussions = { discussion.original_line_code => discussion }
= render partial: "projects/diffs/line",
- collection: discussion.truncated_diff_lines,
+ collection: discussion.highlighted_diff_lines(discussion.truncated_diff_lines),
as: :line,
locals: { diff_file: diff_file,
discussions: discussions,
diff --git a/app/views/notify/_note_mr_or_commit_email.html.haml b/app/views/notify/_note_mr_or_commit_email.html.haml
index 3e2046aa9cf..7033842b557 100644
--- a/app/views/notify/_note_mr_or_commit_email.html.haml
+++ b/app/views/notify/_note_mr_or_commit_email.html.haml
@@ -1,15 +1,16 @@
= content_for :head do
= stylesheet_link_tag 'mailers/highlighted_diff_email'
-- if note.diff_note? && note.diff_file
- = link_to note.diff_file.file_path, @target_url, class: 'details'
+- if @note.diff_note? && @note.diff_file
+ on
+ = link_to @note.diff_file.file_path, @target_url, class: 'details'
\:
%table
= render partial: "projects/diffs/line",
- collection: discussion.truncated_diff_lines,
+ collection: @discussion.highlighted_diff_lines(@discussion.truncated_diff_lines),
as: :line,
- locals: { diff_file: note.diff_file,
+ locals: { diff_file: @note.diff_file,
plain: true,
email: true }
diff --git a/app/views/notify/_simple_diff.text.erb b/app/views/notify/_simple_diff.text.erb
new file mode 100644
index 00000000000..a5a796bc168
--- /dev/null
+++ b/app/views/notify/_simple_diff.text.erb
@@ -0,0 +1,4 @@
+<% lines = @discussion.truncated_diff_lines %>
+<% @discussion.text_parsed_diff_lines(lines).each do |line| %>
+ <%= line %>
+<% end %>
diff --git a/app/views/notify/note_commit_email.html.haml b/app/views/notify/note_commit_email.html.haml
index f4293a3aa50..17dcf36689f 100644
--- a/app/views/notify/note_commit_email.html.haml
+++ b/app/views/notify/note_commit_email.html.haml
@@ -1,7 +1,5 @@
%p.details
New comment for Commit
= @commit.short_id
- on
- = render partial: 'note_mr_or_commit_email',
- locals: { note: @note,
- discussion: @discussion}
+
+ = render 'note_mr_or_commit_email'
diff --git a/app/views/notify/note_commit_email.text.erb b/app/views/notify/note_commit_email.text.erb
index a1ef9858021..715e58af61c 100644
--- a/app/views/notify/note_commit_email.text.erb
+++ b/app/views/notify/note_commit_email.text.erb
@@ -2,6 +2,8 @@ New comment for Commit <%= @commit.short_id %>
<%= url_for(namespace_project_commit_url(@note.project.namespace, @note.project, id: @commit.id, anchor: "note_#{@note.id}")) %>
+<%= render 'simple_diff' if @discussion %>
+
<% if current_application_settings.email_author_in_body %>
<%= @note.author_name %> wrote:
<% end %>
diff --git a/app/views/notify/note_merge_request_email.html.haml b/app/views/notify/note_merge_request_email.html.haml
index 75250b0383d..b7758f191dc 100644
--- a/app/views/notify/note_merge_request_email.html.haml
+++ b/app/views/notify/note_merge_request_email.html.haml
@@ -1,7 +1,5 @@
%p.details
New comment for Merge Request
= @merge_request.to_reference
- on
- = render partial: 'note_mr_or_commit_email',
- locals: { note: @note,
- discussion: @discussion}
+
+ = render 'note_mr_or_commit_email'
diff --git a/app/views/notify/note_merge_request_email.text.erb b/app/views/notify/note_merge_request_email.text.erb
index 42d29b34ebc..d24e15af91f 100644
--- a/app/views/notify/note_merge_request_email.text.erb
+++ b/app/views/notify/note_merge_request_email.text.erb
@@ -2,6 +2,8 @@ New comment for Merge Request <%= @merge_request.to_reference %>
<%= url_for(namespace_project_merge_request_url(@merge_request.target_project.namespace, @merge_request.target_project, @merge_request, anchor: "note_#{@note.id}")) %>
+<%= render 'simple_diff' if @discussion %>
+
<% if current_application_settings.email_author_in_body %>
<%= @note.author_name %> wrote:
<% end %>