From 8b89ef8639b2b6ee69d991fb0d6089f9437bbee2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 17 Dec 2013 15:30:15 +0200 Subject: [PATCH] Add templates for Emails on push Signed-off-by: Dmitriy Zaporozhets --- app/mailers/emails/projects.rb | 2 +- .../notify/repository_push_email.html.haml | 23 +++++++++++++++++++ .../notify/repository_push_email.text.haml | 20 ++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 app/views/notify/repository_push_email.html.haml create mode 100644 app/views/notify/repository_push_email.text.haml diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index beecf15399c..809ce323958 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -16,7 +16,7 @@ module Emails def repository_push_email(project_id, recipient, branch, compare) @project = Project.find project_id - @commits = compare.commits + @commits = Commit.decorate compare.commits @commit = compare.commit @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 new file mode 100644 index 00000000000..48c3b3277bf --- /dev/null +++ b/app/views/notify/repository_push_email.html.haml @@ -0,0 +1,23 @@ +%h3 New push to #{@branch} at #{@project.name_with_namespace} + +%h4 Commits: + +%ul + - @commits.each do |commit| + %li + #{commit.short_id} - #{commit.title} + +%h4 Diff: +- @diffs.each do |diff| + %li + %strong + - if diff.old_path == diff.new_path + = diff.new_path + - elsif diff.new_path && diff.old_path + #{diff.old_path} → #{diff.new_path} + - else + = diff.new_path || diff.old_path + %hr + %pre + = diff.diff + %br diff --git a/app/views/notify/repository_push_email.text.haml b/app/views/notify/repository_push_email.text.haml new file mode 100644 index 00000000000..0da5b9513ee --- /dev/null +++ b/app/views/notify/repository_push_email.text.haml @@ -0,0 +1,20 @@ +New push to #{@branch} at #{@project.name_with_namespace} + +\ +Commits: +- @commits.each do |commit| + #{commit.short_id} - #{truncate(commit.title, length: 40)} +\ +\ +Diff: +- @diffs.each do |diff| + \ + \===================================== + - if diff.old_path == diff.new_path + = diff.new_path + - elsif diff.new_path && diff.old_path + #{diff.old_path} → #{diff.new_path} + - else + = diff.new_path || diff.old_path + \===================================== + = diff.diff