Commit 10a486b3 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Remove YAML processor refactoring stubs and fix specs

parent 241197c2
...@@ -26,7 +26,7 @@ module Gitlab ...@@ -26,7 +26,7 @@ module Gitlab
def matches_pattern?(pattern, pipeline) def matches_pattern?(pattern, pipeline)
return true if pipeline.tag? && pattern == 'tags' return true if pipeline.tag? && pattern == 'tags'
return true if !pipeline.tag? && pattern == 'branches' return true if pipeline.branch? && pattern == 'branches'
return true if source_to_pattern(pipeline.source) == pattern return true if source_to_pattern(pipeline.source) == pattern
if pattern.first == "/" && pattern.last == "/" if pattern.first == "/" && pattern.last == "/"
......
...@@ -22,28 +22,12 @@ module Gitlab ...@@ -22,28 +22,12 @@ module Gitlab
end end
# REFACTORING STUB, remove this method, used only in tests.
#
def builds_for_stage_and_ref(stage, ref, tag = false, source = nil)
pipeline_stage_builds(stage, ::Ci::Pipeline.new(ref: ref, source: source, tag: tag))
end
def builds def builds
@jobs.map do |name, _| @jobs.map do |name, _|
build_attributes(name) build_attributes(name)
end end
end end
def stage_seeds(pipeline)
seeds = @stages.uniq.map do |stage|
builds = pipeline_stage_builds(stage, pipeline)
Gitlab::Ci::Stage::Seed.new(pipeline, stage, builds) if builds.any?
end
seeds.compact
end
def build_attributes(name) def build_attributes(name)
job = @jobs[name.to_sym] || {} job = @jobs[name.to_sym] || {}
...@@ -71,21 +55,8 @@ module Gitlab ...@@ -71,21 +55,8 @@ module Gitlab
}.compact } }.compact }
end end
def self.validation_message(content)
return 'Please provide content of .gitlab-ci.yml' if content.blank?
begin
Gitlab::Ci::YamlProcessor.new(content)
nil
rescue ValidationError, Psych::SyntaxError => e
e.message
end
end
private
def pipeline_stage_builds(stage, pipeline) def pipeline_stage_builds(stage, pipeline)
stage_jobs = @jobs.select do |_, job| selected_jobs = @jobs.select do |_, job|
next unless job[:stage] == stage next unless job[:stage] == stage
only_specs = Gitlab::Ci::Build::Policy only_specs = Gitlab::Ci::Build::Policy
...@@ -97,9 +68,32 @@ module Gitlab ...@@ -97,9 +68,32 @@ module Gitlab
except_specs.none? { |spec| spec.satisfied_by?(pipeline, path: @path) } except_specs.none? { |spec| spec.satisfied_by?(pipeline, path: @path) }
end end
stage_jobs.map { |_, job| build_attributes(job[:name]) } selected_jobs.map { |_, job| build_attributes(job[:name]) }
end
def stage_seeds(pipeline)
seeds = @stages.uniq.map do |stage|
builds = pipeline_stage_builds(stage, pipeline)
Gitlab::Ci::Stage::Seed.new(pipeline, stage, builds) if builds.any?
end
seeds.compact
end
def self.validation_message(content)
return 'Please provide content of .gitlab-ci.yml' if content.blank?
begin
Gitlab::Ci::YamlProcessor.new(content)
nil
rescue ValidationError, Psych::SyntaxError => e
e.message
end
end end
private
def initial_parsing def initial_parsing
## ##
# Global config # Global config
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment