summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2023-08-25 16:18:01 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-08-28 11:15:34 +0900
commit80f35d96ae60fdf238ff62982094b4b4dbd13ecf (patch)
treec95db7a866182d2ecdc6a47b21156d730208aede
parent2edf9fa23a78da59b5ff0d67a16037aecd38a00f (diff)
[rubygems/rubygems] Don't check for circular deps on full index sources
https://github.com/rubygems/rubygems/commit/d275cdccb1
-rw-r--r--lib/bundler/resolver.rb12
-rw-r--r--spec/bundler/resolver/basic_spec.rb23
-rw-r--r--spec/bundler/support/indexes.rb10
3 files changed, 41 insertions, 4 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index fa95ff879b..3263913b7f 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -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
diff --git a/spec/bundler/resolver/basic_spec.rb b/spec/bundler/resolver/basic_spec.rb
index f739f8c02b..151d10c61c 100644
--- a/spec/bundler/resolver/basic_spec.rb
+++ b/spec/bundler/resolver/basic_spec.rb
@@ -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
diff --git a/spec/bundler/support/indexes.rb b/spec/bundler/support/indexes.rb
index 78372302f1..14f515f870 100644
--- a/spec/bundler/support/indexes.rb
+++ b/spec/bundler/support/indexes.rb
@@ -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