[rubygems/rubygems] Don't check for circular deps on full index sources

https://github.com/rubygems/rubygems/commit/d275cdccb1
This commit is contained in:
David Rodríguez 2023-08-25 16:18:01 +02:00 committed by Hiroshi SHIBATA
parent 2edf9fa23a
commit 80f35d96ae
3 changed files with 41 additions and 4 deletions

View File

@ -37,8 +37,16 @@ module Bundler
root_version = Resolver::Candidate.new(0)
@all_specs = Hash.new do |specs, name|
matches = source_for(name).specs.search(name)
matches = filter_invalid_self_dependencies(matches, name)
source = source_for(name)
matches = source.specs.search(name)
# Don't bother to check for circular deps when no dependency API are
# available, since it's too slow to be usable. That edge case won't work
# but resolution other than that should work fine and reasonably fast.
if source.respond_to?(:dependency_api_available?) && source.dependency_api_available?
matches = filter_invalid_self_dependencies(matches, name)
end
specs[name] = matches.sort_by {|s| [s.version, s.platform.to_s] }
end

View File

@ -347,4 +347,27 @@ RSpec.describe "Resolving" do
should_resolve_as %w[rack-3.0.0 standalone_migrations-1.0.13]
end
it "does not ignore versions that incorrectly depend on themselves when dependency_api is not available" do
@index = build_index do
gem "rack", "3.0.0"
gem "standalone_migrations", "7.1.0" do
dep "rack", "~> 2.0"
end
gem "standalone_migrations", "2.0.4" do
dep "standalone_migrations", ">= 2.0.5"
end
gem "standalone_migrations", "1.0.13" do
dep "rack", ">= 0"
end
end
dep "rack", "~> 3.0"
dep "standalone_migrations"
should_resolve_without_dependency_api %w[rack-3.0.0 standalone_migrations-2.0.4]
end
end

View File

@ -14,9 +14,9 @@ module Spec
alias_method :platforms, :platform
def resolve(args = [])
def resolve(args = [], dependency_api_available: true)
@platforms ||= ["ruby"]
default_source = instance_double("Bundler::Source::Rubygems", :specs => @index, :to_s => "locally install gems")
default_source = instance_double("Bundler::Source::Rubygems", :specs => @index, :to_s => "locally install gems", :dependency_api_available? => dependency_api_available)
source_requirements = { :default => default_source }
base = args[0] || Bundler::SpecSet.new([])
base.each {|ls| ls.source = default_source }
@ -41,6 +41,12 @@ module Spec
expect(got).to eq(specs.sort)
end
def should_resolve_without_dependency_api(specs)
got = resolve(:dependency_api_available => false)
got = got.map(&:full_name).sort
expect(got).to eq(specs.sort)
end
def should_resolve_and_include(specs, args = [])
got = resolve(args)
got = got.map(&:full_name).sort