summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-17 16:20:45 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-17 16:20:45 +0200
commit074efd8fd57736bcec25b2f08324b9d25aa886d5 (patch)
tree5f22a0a2e78ed917cbca5bca41ed1ebcb40f6782 /app/models
parent8b89ef8639b2b6ee69d991fb0d6089f9437bbee2 (diff)
downloadgitlab-ce-074efd8fd57736bcec25b2f08324b9d25aa886d5.tar.gz
Email on push: dont send email if new branch was pushed or branch was removed
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project_services/emails_on_push_service.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb
index 1d4828fe720..8df7313f987 100644
--- a/app/models/project_services/emails_on_push_service.rb
+++ b/app/models/project_services/emails_on_push_service.rb
@@ -36,11 +36,20 @@ class EmailsOnPushService < Service
before_sha = push_data[:before]
after_sha = push_data[:after]
branch = push_data[:ref]
+ author_id = push_data[:user_id]
+
+ if before_sha =~ /^000000/ || after_sha =~ /^000000/
+ # skip if new branch was pushed or branch was removed
+ return true
+ end
compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha)
+ # Do not send emails if git compare failed
+ return false unless compare && compare.commits.present?
+
recipients.split(" ").each do |recipient|
- Notify.delay.repository_push_email(project_id, recipient, branch, compare)
+ Notify.delay.repository_push_email(project_id, recipient, author_id, branch, compare)
end
end