summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-09-12 18:55:49 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-09-12 18:55:49 +0800
commit683d8b7f007ad750d088b074e50339c66bf5dd82 (patch)
treec7cc1a74bab1e82aa446e67eff87a4fc1decaab5
parent45afdbef0de58f6de207b057e47151611d2ad7e6 (diff)
downloadgitlab-ce-683d8b7f007ad750d088b074e50339c66bf5dd82.tar.gz
Fix the ordering of transition callbacks:
Because pipeline status could be changed for the builds in the next stages, if we process next stages first, the current build would be out of synchronized, and would need a reload for that matter. Alternatively, like what I did in this commit, we could process the next stages later (by using `after_transition` rather than `around_transition`), and complete what're doing for the current build first. This way we don't have to reload because nothing is out synchronized. Note that since giving `false` in `after_transition` would halt the callbacks chain, according to: https://github.com/state-machines/state_machines-activemodel/blob/v0.4.0/lib/state_machines/integrations/active_model.rb#L426-L429 We'll need to make sure we're not returning false because we don't intend to interrupt the chain. This fixes #22010. After this fix, both pipeline events and build events would only show up once.
-rw-r--r--app/models/commit_status.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 4a628924499..438f807b118 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -69,17 +69,15 @@ class CommitStatus < ActiveRecord::Base
commit_status.update_attributes finished_at: Time.now
end
- # We use around_transition to process pipeline on next stages as soon as possible, before the `after_*` is executed
- around_transition any => [:success, :failed, :canceled] do |commit_status, block|
- block.call
-
- commit_status.pipeline.try(:process!)
- end
-
after_transition do |commit_status, transition|
commit_status.pipeline.try(:build_updated) unless transition.loopback?
end
+ after_transition any => [:success, :failed, :canceled] do |commit_status|
+ commit_status.pipeline.try(:process!)
+ true
+ end
+
after_transition [:created, :pending, :running] => :success do |commit_status|
MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status)
end