Skip to content

Commit 80f35d9

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Don't check for circular deps on full index sources
rubygems/rubygems@d275cdccb1
1 parent 2edf9fa commit 80f35d9

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

lib/bundler/resolver.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ def setup_solver
3737
root_version = Resolver::Candidate.new(0)
3838

3939
@all_specs = Hash.new do |specs, name|
40-
matches = source_for(name).specs.search(name)
41-
matches = filter_invalid_self_dependencies(matches, name)
40+
source = source_for(name)
41+
matches = source.specs.search(name)
42+
43+
# Don't bother to check for circular deps when no dependency API are
44+
# available, since it's too slow to be usable. That edge case won't work
45+
# but resolution other than that should work fine and reasonably fast.
46+
if source.respond_to?(:dependency_api_available?) && source.dependency_api_available?
47+
matches = filter_invalid_self_dependencies(matches, name)
48+
end
49+
4250
specs[name] = matches.sort_by {|s| [s.version, s.platform.to_s] }
4351
end
4452

spec/bundler/resolver/basic_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,27 @@
347347

348348
should_resolve_as %w[rack-3.0.0 standalone_migrations-1.0.13]
349349
end
350+
351+
it "does not ignore versions that incorrectly depend on themselves when dependency_api is not available" do
352+
@index = build_index do
353+
gem "rack", "3.0.0"
354+
355+
gem "standalone_migrations", "7.1.0" do
356+
dep "rack", "~> 2.0"
357+
end
358+
359+
gem "standalone_migrations", "2.0.4" do
360+
dep "standalone_migrations", ">= 2.0.5"
361+
end
362+
363+
gem "standalone_migrations", "1.0.13" do
364+
dep "rack", ">= 0"
365+
end
366+
end
367+
368+
dep "rack", "~> 3.0"
369+
dep "standalone_migrations"
370+
371+
should_resolve_without_dependency_api %w[rack-3.0.0 standalone_migrations-2.0.4]
372+
end
350373
end

spec/bundler/support/indexes.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def platform(*args)
1414

1515
alias_method :platforms, :platform
1616

17-
def resolve(args = [])
17+
def resolve(args = [], dependency_api_available: true)
1818
@platforms ||= ["ruby"]
19-
default_source = instance_double("Bundler::Source::Rubygems", :specs => @index, :to_s => "locally install gems")
19+
default_source = instance_double("Bundler::Source::Rubygems", :specs => @index, :to_s => "locally install gems", :dependency_api_available? => dependency_api_available)
2020
source_requirements = { :default => default_source }
2121
base = args[0] || Bundler::SpecSet.new([])
2222
base.each {|ls| ls.source = default_source }
@@ -41,6 +41,12 @@ def should_resolve_as(specs)
4141
expect(got).to eq(specs.sort)
4242
end
4343

44+
def should_resolve_without_dependency_api(specs)
45+
got = resolve(:dependency_api_available => false)
46+
got = got.map(&:full_name).sort
47+
expect(got).to eq(specs.sort)
48+
end
49+
4450
def should_resolve_and_include(specs, args = [])
4551
got = resolve(args)
4652
got = got.map(&:full_name).sort

0 commit comments

Comments
 (0)