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:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-22 17:22:50 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-03-22 17:22:50 +0300
commitb40d5d0fbb4d61ab8d5ee393eb91a395fb70b236 (patch)
treed67c997340c598f363a60a19da6fd3c22a0f03e4 /lib/gitlab/ci/yaml_processor.rb
parentb9e329769e4bcc688133a763ea85318abb88aaaa (diff)
Fix static analysis and tests related to YAML processing
Diffstat (limited to 'lib/gitlab/ci/yaml_processor.rb')
-rw-r--r--lib/gitlab/ci/yaml_processor.rb44
1 files changed, 14 insertions, 30 deletions
diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb
index 6074829e152..bc2a6f98dae 100644
--- a/lib/gitlab/ci/yaml_processor.rb
+++ b/lib/gitlab/ci/yaml_processor.rb
@@ -27,7 +27,7 @@ module Gitlab
end
def build_attributes(name)
- job = @jobs[name.to_sym] || {}
+ job = @jobs.fetch(name.to_sym, {})
{ stage_idx: @stages.index(job[:stage]),
stage: job[:stage],
@@ -53,39 +53,23 @@ module Gitlab
}.compact }
end
- # REFACTORING, this needs improvement, and specs
- #
- def stage_attributes(stage)
- selected = @jobs.values.select do |job|
- job[:stage] == stage
- end
-
- selected.map do |job|
- build_attributes(job[:name])
- end
+ def stage_builds_attributes(stage)
+ @jobs.values
+ .select { |job| job[:stage] == stage }
+ .map { |job| build_attributes(job[:name]) }
end
- # REFACTORING, needs specs
- #
- def seed_attributes(stage)
- seeds = stage_attributes(stage).map do |attributes|
- job = @jobs.fetch(attributes[:name].to_sym)
-
- attributes
- .merge(only: job.fetch(:only, {}))
- .merge(except: job.fetch(:except, {}))
- end
+ def stages_attributes
+ @stages.uniq.map do |stage|
+ seeds = stage_builds_attributes(stage).map do |attributes|
+ job = @jobs.fetch(attributes[:name].to_sym)
- { name: stage,
- index: @stages.index(stage),
- builds: seeds }
- end
+ attributes
+ .merge(only: job.fetch(:only, {}))
+ .merge(except: job.fetch(:except, {}))
+ end
- # REFACTORING, needs specs
- #
- def stages
- @stages.uniq.map do |stage|
- seed_attributes(stage)
+ { name: stage, index: @stages.index(stage), builds: seeds }
end
end