diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-15 10:05:36 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-15 10:11:09 +0200 |
commit | a76cbe5292d20cd6fdac4e519b65df1ee3544371 (patch) | |
tree | 17a6229241a42e33b4b6e26b076aaad0d184bead | |
parent | bf990fcda4c5b728272d3775cdefadce6f80cf01 (diff) | |
download | gitlab-ce-a76cbe5292d20cd6fdac4e519b65df1ee3544371.tar.gz |
Add note for short circuit eval when building builds
-rw-r--r-- | app/models/ci/pipeline.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index e90924af312..fde03f21f9b 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -93,6 +93,11 @@ module Ci def build_builds(user, trigger_request = nil, status = 'success') return unless config_processor + + ## + # Note that `Array#any?` implements a short circuit evaluation, so we + # build builds only for the first stage that has builds available. + # config_processor.stages.any? do |stage| build_builds_for_stage(stage, user, status, trigger_request).present? end @@ -117,9 +122,14 @@ module Ci prior_builds = latest_builds.where.not(stage: next_stages) prior_status = prior_builds.status - # create builds for next stages based + ## + # Create builds for next stages based. + # + # Note that there is a short circult evaluation here. + # have_builds = next_stages.any? do |stage| - build_builds_for_stage(stage, build.user, prior_status, build.trigger_request).present? + build_builds_for_stage(stage, build.user, prior_status, + build.trigger_request).present? end save! if have_builds |