[rubygems/rubygems] Fix --prefer-local
not respecting default gems
https://github.com/rubygems/rubygems/commit/3df86cd9c6
This commit is contained in:
parent
891ecc63ac
commit
ee7b74799c
@ -220,6 +220,8 @@ module Bundler
|
||||
|
||||
def prefer_local!
|
||||
@prefer_local = true
|
||||
|
||||
sources.prefer_local!
|
||||
end
|
||||
|
||||
# For given dependency list returns a SpecSet with Gemspec of all the required
|
||||
|
@ -193,7 +193,7 @@ module Bundler
|
||||
def install(options)
|
||||
standalone = options[:standalone]
|
||||
force = options[:force]
|
||||
local = options[:local]
|
||||
local = options[:local] || options[:"prefer-local"]
|
||||
jobs = installation_parallelization
|
||||
spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
|
||||
spec_installations.each do |installation|
|
||||
|
@ -35,6 +35,8 @@ module Bundler
|
||||
spec.source == self
|
||||
end
|
||||
|
||||
def prefer_local!; end
|
||||
|
||||
def local!; end
|
||||
|
||||
def local_only!; end
|
||||
|
@ -19,6 +19,7 @@ module Bundler
|
||||
@allow_remote = false
|
||||
@allow_cached = false
|
||||
@allow_local = options["allow_local"] || false
|
||||
@prefer_local = false
|
||||
@checksum_store = Checksum::Store.new
|
||||
|
||||
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
|
||||
@ -30,6 +31,10 @@ module Bundler
|
||||
@caches ||= [cache_path, *Bundler.rubygems.gem_cache]
|
||||
end
|
||||
|
||||
def prefer_local!
|
||||
@prefer_local = true
|
||||
end
|
||||
|
||||
def local_only!
|
||||
@specs = nil
|
||||
@allow_local = true
|
||||
@ -37,6 +42,10 @@ module Bundler
|
||||
@allow_remote = false
|
||||
end
|
||||
|
||||
def local_only?
|
||||
@allow_local && !@allow_remote
|
||||
end
|
||||
|
||||
def local!
|
||||
return if @allow_local
|
||||
|
||||
@ -139,9 +148,15 @@ module Bundler
|
||||
index.merge!(cached_specs) if @allow_cached
|
||||
index.merge!(installed_specs) if @allow_local
|
||||
|
||||
# complete with default specs, only if not already available in the
|
||||
# index through remote, cached, or installed specs
|
||||
index.use(default_specs) if @allow_local
|
||||
if @allow_local
|
||||
if @prefer_local
|
||||
index.merge!(default_specs)
|
||||
else
|
||||
# complete with default specs, only if not already available in the
|
||||
# index through remote, cached, or installed specs
|
||||
index.use(default_specs)
|
||||
end
|
||||
end
|
||||
|
||||
index
|
||||
end
|
||||
|
@ -141,6 +141,10 @@ module Bundler
|
||||
different_sources?(lock_sources, replacement_sources)
|
||||
end
|
||||
|
||||
def prefer_local!
|
||||
all_sources.each(&:prefer_local!)
|
||||
end
|
||||
|
||||
def local_only!
|
||||
all_sources.each(&:local_only!)
|
||||
end
|
||||
|
5
spec/bundler/cache/gems_spec.rb
vendored
5
spec/bundler/cache/gems_spec.rb
vendored
@ -113,6 +113,11 @@ RSpec.describe "bundle cache" do
|
||||
expect(out).to include("Using json #{default_json_version}")
|
||||
end
|
||||
|
||||
it "does not use remote gems when installing with --prefer-local flag" do
|
||||
install_gemfile %(source "https://gem.repo2"; gem 'json', '#{default_json_version}'), verbose: true, "prefer-local": true
|
||||
expect(out).to include("Using json #{default_json_version}")
|
||||
end
|
||||
|
||||
it "caches remote and builtin gems" do
|
||||
install_gemfile <<-G
|
||||
source "https://gem.repo2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user