diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2023-03-16 20:11:18 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-03-23 17:18:49 +0900 |
commit | ebebc90ec297c945cdf94c90f8db85dd7ddbcb7b (patch) | |
tree | b9ae53f98da645ebab294491c994746da8f2306e /lib/bundler/spec_set.rb | |
parent | 8e6bbc032c1bde617a45e418af697831df471083 (diff) |
Refactor incomplete specs handling
Recent bugs fixed made me realize we were relying on state too much
here. We only need to keep incomplete specs to be able to expire them
and retry resolution without them locked. If we use a separate class, we
can do that more transparently and handle them just like we handle
"missing specs".
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7582
Diffstat (limited to 'lib/bundler/spec_set.rb')
-rw-r--r-- | lib/bundler/spec_set.rb | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index cf63c16a70..2361fc356c 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -7,11 +7,8 @@ module Bundler include Enumerable include TSort - attr_reader :incomplete_specs - - def initialize(specs, incomplete_specs = []) + def initialize(specs) @specs = specs - @incomplete_specs = incomplete_specs end def for(dependencies, check = false, platforms = [nil]) @@ -45,7 +42,7 @@ module Bundler end if incomplete && check - @incomplete_specs += lookup[name].any? ? lookup[name] : [LazySpecification.new(name, nil, nil)] + specs << IncompleteSpecification.new(name, lookup[name]) end end @@ -84,7 +81,7 @@ module Bundler def materialize(deps) materialized = self.for(deps, true) - SpecSet.new(materialized, incomplete_specs) + SpecSet.new(materialized) end # Materialize for all the specs in the spec set, regardless of what platform they're for @@ -103,17 +100,19 @@ module Bundler def incomplete_ruby_specs?(deps) return false if @specs.empty? - @incomplete_specs = [] - - self.for(deps, true, [Gem::Platform::RUBY]) + materialized = self.for(deps, true, [Gem::Platform::RUBY]) - @incomplete_specs.any? + SpecSet.new(materialized).incomplete_specs.any? end def missing_specs @specs.select {|s| s.is_a?(LazySpecification) } end + def incomplete_specs + @specs.select {|s| s.is_a?(IncompleteSpecification) } + end + def merge(set) arr = sorted.dup set.each do |set_spec| |