Commit d550933907a51aa6cf5ed8b042db2f7e3323fa8c
1 parent
2428a0b2
Exists in
master
and in
4 other branches
Add new method to mailer for deliver emails with push info
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
21 additions
and
3 deletions
Show diff stats
app/mailers/emails/projects.rb
... | ... | @@ -13,5 +13,15 @@ module Emails |
13 | 13 | mail(to: @user.email, |
14 | 14 | subject: subject("Project was moved")) |
15 | 15 | end |
16 | + | |
17 | + def repository_push_email(project_id, recipient, branch, compare) | |
18 | + @project = Project.find project_id | |
19 | + @commits = compare.commits | |
20 | + @commit = compare.commit | |
21 | + @diffs = compare.diffs | |
22 | + @branch = branch | |
23 | + | |
24 | + mail(to: recipient, subject: subject("New push to repository")) | |
25 | + end | |
16 | 26 | end |
17 | 27 | end | ... | ... |
app/models/project_services/emails_on_push_service.rb
... | ... | @@ -32,8 +32,16 @@ class EmailsOnPushService < Service |
32 | 32 | 'emails_on_push' |
33 | 33 | end |
34 | 34 | |
35 | - def execute | |
36 | - true | |
35 | + def execute(push_data) | |
36 | + before_sha = push_data[:before] | |
37 | + after_sha = push_data[:after] | |
38 | + branch = push_data[:ref] | |
39 | + | |
40 | + compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha) | |
41 | + | |
42 | + recipients.split(" ").each do |recipient| | |
43 | + Notify.delay.repository_push_email(project_id, recipient, branch, compare) | |
44 | + end | |
37 | 45 | end |
38 | 46 | |
39 | 47 | def fields | ... | ... |
app/views/projects/services/_form.html.haml
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | - if type == 'text' |
35 | 35 | = f.text_field name, class: "input-xlarge", placeholder: placeholder |
36 | 36 | - elsif type == 'textarea' |
37 | - = f.text_area name, rows: 5, class: "input-xlarge", placeholder: placeholder | |
37 | + = f.text_area name, rows: 5, class: "input-xxlarge", placeholder: placeholder | |
38 | 38 | - elsif type == 'checkbox' |
39 | 39 | = f.check_box name |
40 | 40 | ... | ... |