Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/admin/services_controller.rb2
-rw-r--r--app/controllers/projects/services_controller.rb2
-rw-r--r--app/mailers/emails/projects.rb3
-rw-r--r--app/models/project_services/emails_on_push_service.rb8
-rw-r--r--app/views/notify/repository_push_email.html.haml45
-rw-r--r--app/views/notify/repository_push_email.text.haml30
-rw-r--r--app/workers/emails_on_push_worker.rb12
7 files changed, 60 insertions, 42 deletions
diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb
index 88106b2418a..44a3f1379d8 100644
--- a/app/controllers/admin/services_controller.rb
+++ b/app/controllers/admin/services_controller.rb
@@ -46,7 +46,7 @@ class Admin::ServicesController < Admin::ApplicationController
:user_key, :device, :priority, :sound, :bamboo_url, :username, :password,
:build_key, :server, :teamcity_url, :build_type,
:description, :issues_url, :new_issue_url, :restrict_to_branch,
- :send_from_committer_email
+ :send_from_committer_email, :disable_diffs
])
end
end
diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb
index dd3987605e3..b7fd5202f95 100644
--- a/app/controllers/projects/services_controller.rb
+++ b/app/controllers/projects/services_controller.rb
@@ -51,7 +51,7 @@ class Projects::ServicesController < Projects::ApplicationController
:user_key, :device, :priority, :sound, :bamboo_url, :username, :password,
:build_key, :server, :teamcity_url, :build_type,
:description, :issues_url, :new_issue_url, :restrict_to_branch,
- :send_from_committer_email
+ :send_from_committer_email, :disable_diffs
)
end
end
diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb
index 3b60aed6f9e..30959ab6a1e 100644
--- a/app/mailers/emails/projects.rb
+++ b/app/mailers/emails/projects.rb
@@ -16,13 +16,14 @@ module Emails
subject: subject("Project was moved"))
end
- def repository_push_email(project_id, recipient, author_id, branch, compare, send_from_committer_email = false)
+ def repository_push_email(project_id, recipient, author_id, branch, compare, send_from_committer_email = false, disable_diffs = false)
@project = Project.find(project_id)
@author = User.find(author_id)
@compare = compare
@commits = Commit.decorate(compare.commits)
@diffs = compare.diffs
@branch = branch.gsub("refs/heads/", "")
+ @disable_diffs = disable_diffs
@subject = "[#{@project.path_with_namespace}][#{@branch}] "
diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb
index a5653665bfb..e5d6c29c645 100644
--- a/app/models/project_services/emails_on_push_service.rb
+++ b/app/models/project_services/emails_on_push_service.rb
@@ -15,6 +15,7 @@
class EmailsOnPushService < Service
prop_accessor :send_from_committer_email
+ prop_accessor :disable_diffs
prop_accessor :recipients
validates :recipients, presence: true, if: :activated?
@@ -34,13 +35,18 @@ class EmailsOnPushService < Service
self.send_from_committer_email == "1"
end
+ def disable_diffs?
+ self.disable_diffs == "1"
+ end
+
def execute(push_data)
- EmailsOnPushWorker.perform_async(project_id, recipients, push_data, self.send_from_committer_email?)
+ EmailsOnPushWorker.perform_async(project_id, recipients, push_data, send_from_committer_email?, disable_diffs?)
end
def fields
[
{ type: 'checkbox', name: 'send_from_committer_email', title: "Send from committer email if domain matches" },
+ { type: 'checkbox', name: 'disable_diffs', title: "Disable code diffs" },
{ type: 'textarea', name: 'recipients', placeholder: 'Emails separated by whitespace' },
]
end
diff --git a/app/views/notify/repository_push_email.html.haml b/app/views/notify/repository_push_email.html.haml
index 28b87812bcc..49688470cc5 100644
--- a/app/views/notify/repository_push_email.html.haml
+++ b/app/views/notify/repository_push_email.html.haml
@@ -16,7 +16,7 @@
%ul
- @diffs.each_with_index do |diff, i|
%li.file-stats
- %a{href: "#diff-#{i}"}
+ %a{href: "#{@target_url if @disable_diffs}#diff-#{i}" }
- if diff.deleted_file
%span.deleted-file
&minus;
@@ -32,27 +32,28 @@
- else
= diff.new_path
-%h4 Changes:
-- @diffs.each_with_index do |diff, i|
- %li{id: "diff-#{i}"}
- %a{href: @target_url + "#diff-#{i}"}
- - if diff.deleted_file
- %strong
- = diff.old_path
- deleted
- - elsif diff.renamed_file
- %strong
- = diff.old_path
- &rarr;
- %strong
- = diff.new_path
- - else
- %strong
- = diff.new_path
- %hr
- %pre
- = color_email_diff(diff.diff)
- %br
+- unless @disable_diffs
+ %h4 Changes:
+ - @diffs.each_with_index do |diff, i|
+ %li{id: "diff-#{i}"}
+ %a{href: @target_url + "#diff-#{i}"}
+ - if diff.deleted_file
+ %strong
+ = diff.old_path
+ deleted
+ - elsif diff.renamed_file
+ %strong
+ = diff.old_path
+ &rarr;
+ %strong
+ = diff.new_path
+ - else
+ %strong
+ = diff.new_path
+ %hr
+ %pre
+ = color_email_diff(diff.diff)
+ %br
- if @compare.timeout
%h5 Huge diff. To prevent performance issues changes are hidden
diff --git a/app/views/notify/repository_push_email.text.haml b/app/views/notify/repository_push_email.text.haml
index 8ff7a8a99ea..b081121c53a 100644
--- a/app/views/notify/repository_push_email.text.haml
+++ b/app/views/notify/repository_push_email.text.haml
@@ -19,20 +19,22 @@ Commits:
\- + #{diff.new_path}
- else
\- #{diff.new_path}
-\
-\
-Changes:
-- @diffs.each do |diff|
+- unless @disable_diffs
\
- \=====================================
- - if diff.deleted_file
- #{diff.old_path} deleted
- - elsif diff.renamed_file
- #{diff.old_path} → #{diff.new_path}
- - else
- = diff.new_path
- \=====================================
- != diff.diff
-\
+ \
+ Changes:
+ - @diffs.each do |diff|
+ \
+ \=====================================
+ - if diff.deleted_file
+ #{diff.old_path} deleted
+ - elsif diff.renamed_file
+ #{diff.old_path} → #{diff.new_path}
+ - else
+ = diff.new_path
+ \=====================================
+ != diff.diff
- if @compare.timeout
+ \
+ \
Huge diff. To prevent performance issues it was hidden
diff --git a/app/workers/emails_on_push_worker.rb b/app/workers/emails_on_push_worker.rb
index 3814b17a8a2..309772cb5ce 100644
--- a/app/workers/emails_on_push_worker.rb
+++ b/app/workers/emails_on_push_worker.rb
@@ -1,7 +1,7 @@
class EmailsOnPushWorker
include Sidekiq::Worker
- def perform(project_id, recipients, push_data, send_from_committer_email = false)
+ def perform(project_id, recipients, push_data, send_from_committer_email = false, disable_diffs = false)
project = Project.find(project_id)
before_sha = push_data["before"]
after_sha = push_data["after"]
@@ -19,7 +19,15 @@ class EmailsOnPushWorker
return false unless compare && compare.commits.present?
recipients.split(" ").each do |recipient|
- Notify.repository_push_email(project_id, recipient, author_id, branch, compare, send_from_committer_email).deliver
+ Notify.repository_push_email(
+ project_id,
+ recipient,
+ author_id,
+ branch,
+ compare,
+ send_from_committer_email,
+ disable_diffs
+ ).deliver
end
ensure
compare = nil