diff options
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/emails_on_push_worker.rb | 33 |
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, |