Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-03-17 15:55:39 +0300
committerDouwe Maan <douwe@gitlab.com>2015-03-18 16:07:28 +0300
commitbf235053adc60bb0b940ef6fb68a59485bc815aa (patch)
tree217874c9652d91a71983f5e31a032ffc815bc62b /app/workers
parentdbd347bfa00e133da8ac178612ed8c30ef871ca4 (diff)
Send EmailsOnPush email when branch or tag is created or deleted.
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/emails_on_push_worker.rb33
1 files changed, 21 insertions, 12 deletions
diff --git a/app/workers/emails_on_push_worker.rb b/app/workers/emails_on_push_worker.rb
index e59ca81defe..429b29525dc 100644
--- a/app/workers/emails_on_push_worker.rb
+++ b/app/workers/emails_on_push_worker.rb
@@ -5,24 +5,32 @@ class EmailsOnPushWorker
project = Project.find(project_id)
before_sha = push_data["before"]
after_sha = push_data["after"]
- branch = push_data["ref"]
+ ref = push_data["ref"]
author_id = push_data["user_id"]
- if Gitlab::Git.blank_ref?(before_sha) || Gitlab::Git.blank_ref?(after_sha)
- # skip if new branch was pushed or branch was removed
- return true
- end
+ action =
+ if Gitlab::Git.blank_ref?(before_sha)
+ :create
+ elsif Gitlab::Git.blank_ref?(after_sha)
+ :delete
+ else
+ :push
+ end
- compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha)
+ compare = nil
+ reverse_compare = false
+ if action == :push
+ compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha)
- return false if compare.same
+ return false if compare.same
- if compare.commits.empty?
- compare = Gitlab::Git::Compare.new(project.repository.raw_repository, after_sha, before_sha)
+ if compare.commits.empty?
+ compare = Gitlab::Git::Compare.new(project.repository.raw_repository, after_sha, before_sha)
- reverse_compare = true
+ reverse_compare = true
- return false if compare.commits.empty?
+ return false if compare.commits.empty?
+ end
end
recipients.split(" ").each do |recipient|
@@ -30,7 +38,8 @@ class EmailsOnPushWorker
project_id,
recipient,
author_id,
- branch,
+ ref,
+ action,
compare,
reverse_compare,
send_from_committer_email,