diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-22 15:10:38 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-22 15:10:38 +0300 |
commit | 980d813e90c70f09861e39b9269e73b2c9a4e936 (patch) | |
tree | 56bbceba907009181439a7c3a0855418b965b39e /lib/gitlab/ci/variables | |
parent | 2e9f877e8b6dd58c8011745b1d9a28dd67c8179c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci/variables')
-rw-r--r-- | lib/gitlab/ci/variables/collection/sorted.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/gitlab/ci/variables/collection/sorted.rb b/lib/gitlab/ci/variables/collection/sorted.rb index e641df10462..efa9e3bdfc4 100644 --- a/lib/gitlab/ci/variables/collection/sorted.rb +++ b/lib/gitlab/ci/variables/collection/sorted.rb @@ -8,8 +8,11 @@ module Gitlab include TSort include Gitlab::Utils::StrongMemoize - def initialize(variables, project) - @variables = variables + def initialize(collection, project) + raise(ArgumentError, "A Gitlab::Ci::Variables::Collection object was expected") unless + collection.is_a?(Collection) + + @collection = collection @project = project end @@ -35,16 +38,16 @@ module Gitlab # sort sorts an array of variables, ignoring unknown variable references. # If a circular variable reference is found, the original array is returned def sort - return @variables if Feature.disabled?(:variable_inside_variable, @project) - return @variables if errors + return @collection if Feature.disabled?(:variable_inside_variable, @project) + return @collection if errors - tsort + Gitlab::Ci::Variables::Collection.new(tsort) end private def tsort_each_node(&block) - @variables.each(&block) + @collection.each(&block) end def tsort_each_child(variable, &block) @@ -53,7 +56,7 @@ module Gitlab def input_vars strong_memoize(:input_vars) do - @variables.index_by { |env| env.fetch(:key) } + @collection.index_by { |env| env[:key] } end end |