diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-09-08 14:55:36 +0200 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-09-08 14:55:36 +0200 |
commit | df16969c24c608682b8b46883a8e6e20147a3791 (patch) | |
tree | 902880a11b1ca6b488295b88b63b2bd1947ddec8 /lib | |
parent | 776bca5a8f6c3cb714451066f90a98660ae0c8d6 (diff) | |
download | gitlab-ce-df16969c24c608682b8b46883a8e6e20147a3791.tar.gz |
Reconcile differences in lib/gitlab/ci
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config.rb | 26 | ||||
-rw-r--r-- | lib/gitlab/ci/yaml_processor.rb | 2 |
2 files changed, 17 insertions, 11 deletions
diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index 19d93c6e785..0ffd1791791 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -7,14 +7,18 @@ module Gitlab ConfigError = Class.new(StandardError) def initialize(config, opts = {}) - @config = Config::Extendable - .new(build_config(config, opts)) - .to_hash - - @global = Entry::Global.new(@config) - @global.compose! - rescue Loader::FormatError, Extendable::ExtensionError => e - raise Config::ConfigError, e.message + begin + @config = Config::Extendable + .new(build_config(config, opts)) + .to_hash + + @global = Entry::Global.new(@config) + @global.compose! + rescue Loader::FormatError, Extendable::ExtensionError => e + raise Config::ConfigError, e.message + end + rescue ::Gitlab::Ci::External::Processor::FileError => e + raise ::Gitlab::Ci::YamlProcessor::ValidationError, e.message end def valid? @@ -64,6 +68,8 @@ module Gitlab @global.jobs_value end + private + def build_config(config, opts = {}) initial_config = Loader.new(config).load! project = opts.fetch(:project, nil) @@ -76,8 +82,8 @@ module Gitlab end def process_external_files(config, project, opts) - sha = opts.fetch(:sha, project.repository.commit.sha) - ::Gitlab::Ci::External::Processor.new(config, project, sha).perform + sha = opts.fetch(:sha) { project.repository.root_ref_sha } + ::Gitlab::Ci::External::Processor.new(config, project, sha).perform end end end diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index 67f5d2d6ae4..5d1864ae9e2 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -79,7 +79,7 @@ module Gitlab begin Gitlab::Ci::YamlProcessor.new(content, opts) nil - rescue ValidationError, ::Gitlab::Ci::ExternalFiles::Processor::ExternalFileError => e + rescue ValidationError => e e.message end end |