summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-08-04 01:18:33 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-08-04 01:18:33 +0800
commit80671bf75cdac3f50615253b058fa04da6235a4f (patch)
tree3de936265145efc7b7f5f9b374504ba97afe1044
parent431792f78404c4b83aa8c962ff306f4aacd35f8b (diff)
downloadgitlab-ce-80671bf75cdac3f50615253b058fa04da6235a4f.tar.gz
Separate the concern for executing hooks and updating states
-rw-r--r--app/models/ci/pipeline.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index ca41a998a2b..81991e8aa60 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -228,8 +228,18 @@ module Ci
end
def update_state
- statuses.reload
last_status = status
+
+ if update_state_from_commit_statuses
+ execute_hooks if last_status != status && !skip_ci?
+ true
+ else
+ false
+ end
+ end
+
+ def update_state_from_commit_statuses
+ statuses.reload
self.status = if yaml_errors.blank?
statuses.latest.status || 'skipped'
else
@@ -238,9 +248,7 @@ module Ci
self.started_at = statuses.started_at
self.finished_at = statuses.finished_at
self.duration = statuses.latest.duration
- saved = save
- execute_hooks if last_status != status && saved && !skip_ci?
- saved
+ save
end
def execute_hooks