From d550933907a51aa6cf5ed8b042db2f7e3323fa8c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 17 Dec 2013 14:45:55 +0200 Subject: [PATCH] Add new method to mailer for deliver emails with push info --- app/mailers/emails/projects.rb | 10 ++++++++++ app/models/project_services/emails_on_push_service.rb | 12 ++++++++++-- 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 0e40450..beecf15 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 5ead0f2..1d4828f 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 2e2e5f4..34ba55f 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 -- libgit2 0.21.2