Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Merge #7473
Browse files Browse the repository at this point in the history
7473: Cleanup some unnecessary code r=deivid-rodriguez a=deivid-rodriguez

### What was the end-user problem that led to this PR?

The problem was #7460 is very big so I want to extract these changes to a separate PR, so that we're more aware of them.

### What was your diagnosis of the problem?

My diagnosis was that this code can be removed. In particular, in the `GemRemoteFetcher` class there was the following comment

https://github.com/bundler/bundler/blob/25595896eb0f8dfd004d941093bf1d8f4a39aeeb/lib/bundler/gem_remote_fetcher.rb#L9-L10

After having a look, I think the comment would make sense if where it says "gemstash", it actually meant "bundler". That would make sense to me since this is about fetching remote specs, so I would assume it's the client side running it.

Assuming this is the correct interpretation, we can remove the code since our minimum supported rubygems version is 2.5.2, and this code was included in rubygems in 2.5.0.

### What is your fix for the problem, implemented in this PR?

My fix is to remove the `GemRemoteFetcher` class, plus simplify other related code.


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
  • Loading branch information
bundlerbot and deivid-rodriguez committed Dec 8, 2019
2 parents 2559589 + 98a9137 commit bada03d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 58 deletions.
1 change: 0 additions & 1 deletion lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module Bundler
autoload :FeatureFlag, File.expand_path("bundler/feature_flag", __dir__)
autoload :GemHelper, File.expand_path("bundler/gem_helper", __dir__)
autoload :GemHelpers, File.expand_path("bundler/gem_helpers", __dir__)
autoload :GemRemoteFetcher, File.expand_path("bundler/gem_remote_fetcher", __dir__)
autoload :GemVersionPromoter, File.expand_path("bundler/gem_version_promoter", __dir__)
autoload :Graph, File.expand_path("bundler/graph", __dir__)
autoload :Index, File.expand_path("bundler/index", __dir__)
Expand Down
43 changes: 0 additions & 43 deletions lib/bundler/gem_remote_fetcher.rb

This file was deleted.

18 changes: 5 additions & 13 deletions lib/bundler/rubygems_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,6 @@ def ext_lock
EXT_LOCK
end

def fetch_prerelease_specs
fetch_specs(false, true)
rescue Gem::RemoteFetcher::FetchError
{} # if we can't download them, there aren't any
end

def with_build_args(args)
ext_lock.synchronize do
old_args = build_args
Expand Down Expand Up @@ -502,8 +496,8 @@ def stub_rubygems(specs)
end
end

def fetch_specs(source, remote, name)
path = source + "#{name}.#{Gem.marshal_version}.gz"
def fetch_specs(remote, name)
path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
fetcher = gem_remote_fetcher
fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
string = fetcher.fetch_path(path)
Expand All @@ -514,10 +508,8 @@ def fetch_specs(source, remote, name)
end

def fetch_all_remote_specs(remote)
source = remote.uri.is_a?(URI) ? remote.uri : URI.parse(source.to_s)

specs = fetch_specs(source, remote, "specs")
pres = fetch_specs(source, remote, "prerelease_specs") || []
specs = fetch_specs(remote, "specs")
pres = fetch_specs(remote, "prerelease_specs") || []

specs.concat(pres)
end
Expand All @@ -535,7 +527,7 @@ def gem_remote_fetcher
require "resolv"
proxy = configuration[:http_proxy]
dns = Resolv::DNS.new
Bundler::GemRemoteFetcher.new(proxy, dns)
Gem::RemoteFetcher.new(proxy, dns)
end

def gem_from_path(path, policy = nil)
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/rubygems_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
end

describe "#fetch_all_remote_specs" do
let(:uri) { URI("https://example.com") }
let(:uri) { "https://example.com" }
let(:fetcher) { double("gem_remote_fetcher") }
let(:specs_response) { Marshal.dump(["specs"]) }
let(:prerelease_specs_response) { Marshal.dump(["prerelease_specs"]) }
Expand Down

0 comments on commit bada03d

Please sign in to comment.