diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-12-17 14:45:55 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-12-17 14:45:55 +0200 |
commit | d550933907a51aa6cf5ed8b042db2f7e3323fa8c (patch) | |
tree | bf3d1cc1dcb8176b3b072679501ade141b5e7bc4 | |
parent | 2428a0b2dd8e84e285df4b356ee6f1593204cd34 (diff) | |
download | gitlab-ce-d550933907a51aa6cf5ed8b042db2f7e3323fa8c.tar.gz |
Add new method to mailer for deliver emails with push info
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/mailers/emails/projects.rb | 10 | ||||
-rw-r--r-- | app/models/project_services/emails_on_push_service.rb | 12 | ||||
-rw-r--r-- | app/views/projects/services/_form.html.haml | 2 |
3 files changed, 21 insertions, 3 deletions
diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 0e40450bfee..beecf15399c 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -13,5 +13,15 @@ module Emails mail(to: @user.email, subject: subject("Project was moved")) end + + def repository_push_email(project_id, recipient, branch, compare) + @project = Project.find project_id + @commits = compare.commits + @commit = compare.commit + @diffs = compare.diffs + @branch = branch + + mail(to: recipient, subject: subject("New push to repository")) + end end end diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb index 5ead0f2b730..1d4828fe720 100644 --- a/app/models/project_services/emails_on_push_service.rb +++ b/app/models/project_services/emails_on_push_service.rb @@ -32,8 +32,16 @@ class EmailsOnPushService < Service 'emails_on_push' end - def execute - true + def execute(push_data) + before_sha = push_data[:before] + after_sha = push_data[:after] + branch = push_data[:ref] + + compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha) + + recipients.split(" ").each do |recipient| + Notify.delay.repository_push_email(project_id, recipient, branch, compare) + end end def fields diff --git a/app/views/projects/services/_form.html.haml b/app/views/projects/services/_form.html.haml index 2e2e5f41dd8..34ba55fc4cd 100644 --- a/app/views/projects/services/_form.html.haml +++ b/app/views/projects/services/_form.html.haml @@ -34,7 +34,7 @@ - if type == 'text' = f.text_field name, class: "input-xlarge", placeholder: placeholder - elsif type == 'textarea' - = f.text_area name, rows: 5, class: "input-xlarge", placeholder: placeholder + = f.text_area name, rows: 5, class: "input-xxlarge", placeholder: placeholder - elsif type == 'checkbox' = f.check_box name |