Commit 59769fdb940712737656a441ef43a1ad2dd47f4d
1 parent
0bcabdaf
Exists in
spb-stable
and in
3 other branches
Improve compare logic for EmailOnPush service
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
4 changed files
with
13 additions
and
2 deletions
Show diff stats
app/mailers/emails/projects.rb
| @@ -17,6 +17,7 @@ module Emails | @@ -17,6 +17,7 @@ module Emails | ||
| 17 | def repository_push_email(project_id, recipient, author_id, branch, compare) | 17 | def repository_push_email(project_id, recipient, author_id, branch, compare) |
| 18 | @project = Project.find(project_id) | 18 | @project = Project.find(project_id) |
| 19 | @author = User.find(author_id) | 19 | @author = User.find(author_id) |
| 20 | + @compare = compare | ||
| 20 | @commits = Commit.decorate(compare.commits) | 21 | @commits = Commit.decorate(compare.commits) |
| 21 | @diffs = compare.diffs | 22 | @diffs = compare.diffs |
| 22 | @branch = branch | 23 | @branch = branch |
app/views/notify/repository_push_email.html.haml
app/views/notify/repository_push_email.text.haml
| @@ -18,3 +18,8 @@ Diff: | @@ -18,3 +18,8 @@ Diff: | ||
| 18 | = diff.new_path || diff.old_path | 18 | = diff.new_path || diff.old_path |
| 19 | \===================================== | 19 | \===================================== |
| 20 | = diff.diff | 20 | = diff.diff |
| 21 | +\ | ||
| 22 | +- if @compare.timeout | ||
| 23 | + Huge diff. To prevent performance issues it was hidden | ||
| 24 | +- elsif @compare.commits_over_limit? | ||
| 25 | + Diff for big amount of commits is disabled |
app/workers/emails_on_push_worker.rb
| @@ -13,13 +13,13 @@ class EmailsOnPushWorker | @@ -13,13 +13,13 @@ class EmailsOnPushWorker | ||
| 13 | return true | 13 | return true |
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | - compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha) | 16 | + compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha, MergeRequestDiff::COMMITS_SAFE_SIZE) |
| 17 | 17 | ||
| 18 | # Do not send emails if git compare failed | 18 | # Do not send emails if git compare failed |
| 19 | return false unless compare && compare.commits.present? | 19 | return false unless compare && compare.commits.present? |
| 20 | 20 | ||
| 21 | recipients.split(" ").each do |recipient| | 21 | recipients.split(" ").each do |recipient| |
| 22 | - Notify.delay.repository_push_email(project_id, recipient, author_id, branch, compare) | 22 | + Notify.repository_push_email(project_id, recipient, author_id, branch, compare).deliver |
| 23 | end | 23 | end |
| 24 | end | 24 | end |
| 25 | end | 25 | end |