From 59769fdb940712737656a441ef43a1ad2dd47f4d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 12 Feb 2014 12:56:13 +0200 Subject: [PATCH] Improve compare logic for EmailOnPush service --- app/mailers/emails/projects.rb | 1 + app/views/notify/repository_push_email.html.haml | 5 +++++ app/views/notify/repository_push_email.text.haml | 5 +++++ app/workers/emails_on_push_worker.rb | 4 ++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index df21d7b..428d74d 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -17,6 +17,7 @@ module Emails def repository_push_email(project_id, recipient, author_id, branch, compare) @project = Project.find(project_id) @author = User.find(author_id) + @compare = compare @commits = Commit.decorate(compare.commits) @diffs = compare.diffs @branch = branch diff --git a/app/views/notify/repository_push_email.html.haml b/app/views/notify/repository_push_email.html.haml index d0b30c0..ab0d6c6 100644 --- a/app/views/notify/repository_push_email.html.haml +++ b/app/views/notify/repository_push_email.html.haml @@ -21,3 +21,8 @@ %pre = diff.diff %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 diff --git a/app/views/notify/repository_push_email.text.haml b/app/views/notify/repository_push_email.text.haml index 6718ca6..93b344d 100644 --- a/app/views/notify/repository_push_email.text.haml +++ b/app/views/notify/repository_push_email.text.haml @@ -18,3 +18,8 @@ Diff: = diff.new_path || diff.old_path \===================================== = 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 diff --git a/app/workers/emails_on_push_worker.rb b/app/workers/emails_on_push_worker.rb index 9982b36..5e81810 100644 --- a/app/workers/emails_on_push_worker.rb +++ b/app/workers/emails_on_push_worker.rb @@ -13,13 +13,13 @@ class EmailsOnPushWorker return true 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 return false unless compare && compare.commits.present? 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 -- libgit2 0.21.2