Commit faad5120 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-emails-on-push-diff-limit' into 'master'

Fix emails on push diff limit

The diff limits were not respected in the emails-on-push since the refactoring in gitlab-org/gitlab-ce!2705. This was one possible cause for customer issue described in gitlab-org/gitlab-ce#15137.

This MR also brings in the changes in !337 since they are required for this to work.


See merge request !338
parents 940bcc7b 39ada489
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.7.0 (unreleased) v 8.7.0 (unreleased)
- Don't attempt to include too large diffs in e-mail-on-push messages (Stan Hu)
- Update GitLab Pages to 0.2.1: support user-defined 404 pages - Update GitLab Pages to 0.2.1: support user-defined 404 pages
- Refactor group sync to pull access level logic to its own class. !306 - Refactor group sync to pull access level logic to its own class. !306
- [Elastic] Stabilize database indexer if database is inconsistent - [Elastic] Stabilize database indexer if database is inconsistent
......
...@@ -46,8 +46,11 @@ ...@@ -46,8 +46,11 @@
= diff.new_path = diff.new_path
- unless @message.disable_diffs? - unless @message.disable_diffs?
- diff_files = safe_diff_files(@message.diffs, @message.diff_refs) - diff_files = @message.diffs
- if @message.compare_timeout
%h5 The diff was not included because it is too large.
- else
%h4 Changes: %h4 Changes:
- diff_files.each_with_index do |diff_file, i| - diff_files.each_with_index do |diff_file, i|
%li{id: "diff-#{i}"} %li{id: "diff-#{i}"}
...@@ -76,5 +79,3 @@ ...@@ -76,5 +79,3 @@
No preview for this file type No preview for this file type
%br %br
- if @message.compare_timeout
%h5 Huge diff. To prevent performance issues changes are hidden
...@@ -25,24 +25,26 @@ ...@@ -25,24 +25,26 @@
- else - else
\- #{diff.new_path} \- #{diff.new_path}
- unless @message.disable_diffs? - unless @message.disable_diffs?
- if @message.compare_timeout
\
\
The diff was not included because it is too large.
- else
\ \
\ \
Changes: Changes:
- @message.diffs.each do |diff| - @message.diffs.each do |diff_file|
\ \
\===================================== \=====================================
- if diff.deleted_file - if diff_file.deleted_file
#{diff.old_path} deleted #{diff_file.old_path} deleted
- elsif diff.renamed_file - elsif diff_file.renamed_file
#{diff.old_path}#{diff.new_path} #{diff_file.old_path}#{diff_file.new_path}
- else - else
= diff.new_path = diff_file.new_path
\===================================== \=====================================
!= diff.diff != diff_file.diff.diff
- if @message.compare_timeout
\
\
Huge diff. To prevent performance issues it was hidden
- if @message.target_url - if @message.target_url
\ \
\ \
......
...@@ -6,6 +6,7 @@ module Gitlab ...@@ -6,6 +6,7 @@ module Gitlab
attr_reader :author_id, :ref, :action attr_reader :author_id, :ref, :action
include Gitlab::Routing.url_helpers include Gitlab::Routing.url_helpers
include DiffHelper
delegate :namespace, :name_with_namespace, to: :project, prefix: :project delegate :namespace, :name_with_namespace, to: :project, prefix: :project
delegate :name, to: :author, prefix: :author delegate :name, to: :author, prefix: :author
...@@ -38,7 +39,7 @@ module Gitlab ...@@ -38,7 +39,7 @@ module Gitlab
end end
def diffs def diffs
@diffs ||= (compare.diffs if compare) @diffs ||= (safe_diff_files(compare.diffs, diff_refs) if compare)
end end
def diffs_count def diffs_count
......
...@@ -57,7 +57,7 @@ describe Gitlab::Email::Message::RepositoryPush do ...@@ -57,7 +57,7 @@ describe Gitlab::Email::Message::RepositoryPush do
describe '#diffs' do describe '#diffs' do
subject { message.diffs } subject { message.diffs }
it { is_expected.to all(be_an_instance_of Gitlab::Git::Diff) } it { is_expected.to all(be_an_instance_of Gitlab::Diff::File) }
end end
describe '#diffs_count' do describe '#diffs_count' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment