mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-18 17:16:08 +10:00
Add minor improvements in create builds service
This commit is contained in:
@@ -135,7 +135,7 @@ module Ci
|
||||
@config_processor ||= begin
|
||||
Ci::GitlabCiYamlProcessor.new(ci_yaml_file, project.path_with_namespace)
|
||||
rescue Ci::GitlabCiYamlProcessor::ValidationError, Psych::SyntaxError => e
|
||||
self.yaml_errors = (e.message)
|
||||
self.yaml_errors = e.message
|
||||
nil
|
||||
rescue
|
||||
self.yaml_errors = 'Undefined error'
|
||||
|
||||
@@ -2,10 +2,11 @@ module Ci
|
||||
class CreateBuildsService
|
||||
def initialize(commit)
|
||||
@commit = commit
|
||||
@config = commit.config_processor
|
||||
end
|
||||
|
||||
def execute(stage, user, status, trigger_request = nil)
|
||||
builds_attrs = config_processor.builds_for_stage_and_ref(stage, @commit.ref, @commit.tag, trigger_request)
|
||||
builds_attrs = @config.builds_for_stage_and_ref(stage, @commit.ref, @commit.tag, trigger_request)
|
||||
|
||||
# check when to create next build
|
||||
builds_attrs = builds_attrs.select do |build_attrs|
|
||||
@@ -41,11 +42,5 @@ module Ci
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def config_processor
|
||||
@config_processor ||= @commit.config_processor
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,10 @@ module Ci
|
||||
end
|
||||
|
||||
def builds_for_stage_and_ref(stage, ref, tag = false, trigger_request = nil)
|
||||
builds.select{|build| build[:stage] == stage && process?(build[:only], build[:except], ref, tag, trigger_request)}
|
||||
builds.select do |build|
|
||||
build[:stage] == stage &&
|
||||
process?(build[:only], build[:except], ref, tag, trigger_request)
|
||||
end
|
||||
end
|
||||
|
||||
def builds
|
||||
|
||||
@@ -183,7 +183,7 @@ describe CreateCommitBuildsService, services: true do
|
||||
ref: 'refs/heads/master',
|
||||
before: '00000000',
|
||||
after: '31das312',
|
||||
commits: [{ message: 'some msg'}])
|
||||
commits: [{ message: 'some msg'} ])
|
||||
|
||||
expect(result).to be false
|
||||
expect(Ci::Build.all).to be_empty
|
||||
|
||||
Reference in New Issue
Block a user