diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-09-08 15:55:36 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-09-08 15:55:36 +0300 |
commit | df16969c24c608682b8b46883a8e6e20147a3791 (patch) | |
tree | 902880a11b1ca6b488295b88b63b2bd1947ddec8 /lib/gitlab/ci/config.rb | |
parent | 776bca5a8f6c3cb714451066f90a98660ae0c8d6 (diff) |
Reconcile differences in lib/gitlab/ci
Diffstat (limited to 'lib/gitlab/ci/config.rb')
-rw-r--r-- | lib/gitlab/ci/config.rb | 26 |
1 files changed, 16 insertions, 10 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 |