diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-10 12:11:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-10 12:11:07 +0300 |
commit | 16e3c17d3f24314a7a4dfd3c7189701eeb40bf16 (patch) | |
tree | 2da0fa39326060f30b468570b396904bc4ec29b7 /lib/gitlab/ci/variables | |
parent | ff2b80a5548b308f31acce94069bb3fd2e0480c3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ci/variables')
-rw-r--r-- | lib/gitlab/ci/variables/collection.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/ci/variables/collection/sort.rb | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/gitlab/ci/variables/collection.rb b/lib/gitlab/ci/variables/collection.rb index ef9ba1b73c7..73d27399680 100644 --- a/lib/gitlab/ci/variables/collection.rb +++ b/lib/gitlab/ci/variables/collection.rb @@ -10,7 +10,7 @@ module Gitlab def initialize(variables = [], errors = nil) @variables = [] - @variables_by_key = {} + @variables_by_key = Hash.new { |h, k| h[k] = [] } @errors = errors variables.each { |variable| self.append(variable) } @@ -19,7 +19,7 @@ module Gitlab def append(resource) item = Collection::Item.fabricate(resource) @variables.append(item) - @variables_by_key[item[:key]] = item + @variables_by_key[item[:key]] << item self end @@ -46,7 +46,12 @@ module Gitlab end def [](key) - @variables_by_key[key] + all(key)&.last + end + + def all(key) + vars = @variables_by_key[key] + vars unless vars.empty? end def size @@ -72,7 +77,7 @@ module Gitlab match = Regexp.last_match if match[:key] # we matched variable - if variable = @variables_by_key[match[:key]] + if variable = self[match[:key]] variable.value elsif keep_undefined match[0] diff --git a/lib/gitlab/ci/variables/collection/sort.rb b/lib/gitlab/ci/variables/collection/sort.rb index 90a929b8a07..62637825c15 100644 --- a/lib/gitlab/ci/variables/collection/sort.rb +++ b/lib/gitlab/ci/variables/collection/sort.rb @@ -42,7 +42,7 @@ module Gitlab depends_on = var_item.depends_on return unless depends_on - depends_on.filter_map { |var_ref_name| @collection[var_ref_name] }.each(&block) + depends_on.filter_map { |var_ref_name| @collection.all(var_ref_name) }.flatten.each(&block) end end end |