BigW Consortium Gitlab

Improve compare logic for EmailOnPush service

parent 0bcabdaf
...@@ -17,6 +17,7 @@ module Emails ...@@ -17,6 +17,7 @@ module Emails
def repository_push_email(project_id, recipient, author_id, branch, compare) def repository_push_email(project_id, recipient, author_id, branch, compare)
@project = Project.find(project_id) @project = Project.find(project_id)
@author = User.find(author_id) @author = User.find(author_id)
@compare = compare
@commits = Commit.decorate(compare.commits) @commits = Commit.decorate(compare.commits)
@diffs = compare.diffs @diffs = compare.diffs
@branch = branch @branch = branch
......
...@@ -21,3 +21,8 @@ ...@@ -21,3 +21,8 @@
%pre %pre
= diff.diff = diff.diff
%br %br
- if @compare.timeout
%h5 Huge diff. To prevent performance issues it was hidden
- elsif @compare.commits_over_limit?
%h5 Diff for big amount of commits is disabled
...@@ -18,3 +18,8 @@ Diff: ...@@ -18,3 +18,8 @@ Diff:
= diff.new_path || diff.old_path = diff.new_path || diff.old_path
\===================================== \=====================================
= diff.diff = diff.diff
\
- if @compare.timeout
Huge diff. To prevent performance issues it was hidden
- elsif @compare.commits_over_limit?
Diff for big amount of commits is disabled
...@@ -13,13 +13,13 @@ class EmailsOnPushWorker ...@@ -13,13 +13,13 @@ class EmailsOnPushWorker
return true return true
end end
compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha) compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha, MergeRequestDiff::COMMITS_SAFE_SIZE)
# Do not send emails if git compare failed # Do not send emails if git compare failed
return false unless compare && compare.commits.present? return false unless compare && compare.commits.present?
recipients.split(" ").each do |recipient| recipients.split(" ").each do |recipient|
Notify.delay.repository_push_email(project_id, recipient, author_id, branch, compare) Notify.repository_push_email(project_id, recipient, author_id, branch, compare).deliver
end end
end end
end end
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