Skip to content

Commit

Permalink
Merge pull request #6916 from rubygems/speed-up-multiple-global-remot…
Browse files Browse the repository at this point in the history
…es-case

Don't use full indexes unnecessarily on legacy Gemfiles

(cherry picked from commit ef84fd7)
  • Loading branch information
deivid-rodriguez committed Sep 21, 2023
1 parent d51f3a0 commit 4c653b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
15 changes: 5 additions & 10 deletions bundler/lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,11 @@ def remote_specs
@remote_specs ||= Index.build do |idx|
index_fetchers = fetchers - api_fetchers

# gather lists from non-api sites
fetch_names(index_fetchers, nil, idx, false)

# legacy multi-remote sources need special logic to figure out
# dependency names and that logic can be very costly if one remote
# uses the dependency API but others don't. So use full indexes
# consistently in that particular case.
allow_api = !multiple_remotes?

fetch_names(api_fetchers, allow_api && dependency_names, idx, false)
if index_fetchers.empty?
fetch_names(api_fetchers, dependency_names, idx, false)
else
fetch_names(fetchers, nil, idx, false)
end
end
end

Expand Down
9 changes: 9 additions & 0 deletions bundler/spec/install/gemfile/sources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end

it "does not use the full index unnecessarily", :bundler => "< 3" do
bundle :install, :artifice => "compact_index", :verbose => true

expect(out).to include("https://gem.repo1/versions")
expect(out).to include("https://gem.repo3/versions")
expect(out).not_to include("https://gem.repo1/quick/Marshal.4.8/")
expect(out).not_to include("https://gem.repo3/quick/Marshal.4.8/")
end

it "fails", :bundler => "3" do
bundle :install, :artifice => "compact_index", :raise_on_error => false
expect(err).to include("Each source after the first must include a block")
Expand Down

0 comments on commit 4c653b4

Please sign in to comment.