[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!
|
def prefer_local!
|
||||||
@prefer_local = true
|
@prefer_local = true
|
||||||
|
|
||||||
|
sources.prefer_local!
|
||||||
end
|
end
|
||||||
|
|
||||||
# For given dependency list returns a SpecSet with Gemspec of all the required
|
# For given dependency list returns a SpecSet with Gemspec of all the required
|
||||||
|
@ -193,7 +193,7 @@ module Bundler
|
|||||||
def install(options)
|
def install(options)
|
||||||
standalone = options[:standalone]
|
standalone = options[:standalone]
|
||||||
force = options[:force]
|
force = options[:force]
|
||||||
local = options[:local]
|
local = options[:local] || options[:"prefer-local"]
|
||||||
jobs = installation_parallelization
|
jobs = installation_parallelization
|
||||||
spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
|
spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
|
||||||
spec_installations.each do |installation|
|
spec_installations.each do |installation|
|
||||||
|
@ -35,6 +35,8 @@ module Bundler
|
|||||||
spec.source == self
|
spec.source == self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prefer_local!; end
|
||||||
|
|
||||||
def local!; end
|
def local!; end
|
||||||
|
|
||||||
def local_only!; end
|
def local_only!; end
|
||||||
|
@ -19,6 +19,7 @@ module Bundler
|
|||||||
@allow_remote = false
|
@allow_remote = false
|
||||||
@allow_cached = false
|
@allow_cached = false
|
||||||
@allow_local = options["allow_local"] || false
|
@allow_local = options["allow_local"] || false
|
||||||
|
@prefer_local = false
|
||||||
@checksum_store = Checksum::Store.new
|
@checksum_store = Checksum::Store.new
|
||||||
|
|
||||||
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
|
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
|
||||||
@ -30,6 +31,10 @@ module Bundler
|
|||||||
@caches ||= [cache_path, *Bundler.rubygems.gem_cache]
|
@caches ||= [cache_path, *Bundler.rubygems.gem_cache]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prefer_local!
|
||||||
|
@prefer_local = true
|
||||||
|
end
|
||||||
|
|
||||||
def local_only!
|
def local_only!
|
||||||
@specs = nil
|
@specs = nil
|
||||||
@allow_local = true
|
@allow_local = true
|
||||||
@ -37,6 +42,10 @@ module Bundler
|
|||||||
@allow_remote = false
|
@allow_remote = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def local_only?
|
||||||
|
@allow_local && !@allow_remote
|
||||||
|
end
|
||||||
|
|
||||||
def local!
|
def local!
|
||||||
return if @allow_local
|
return if @allow_local
|
||||||
|
|
||||||
@ -139,9 +148,15 @@ module Bundler
|
|||||||
index.merge!(cached_specs) if @allow_cached
|
index.merge!(cached_specs) if @allow_cached
|
||||||
index.merge!(installed_specs) if @allow_local
|
index.merge!(installed_specs) if @allow_local
|
||||||
|
|
||||||
# complete with default specs, only if not already available in the
|
if @allow_local
|
||||||
# index through remote, cached, or installed specs
|
if @prefer_local
|
||||||
index.use(default_specs) if @allow_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
|
index
|
||||||
end
|
end
|
||||||
|
@ -141,6 +141,10 @@ module Bundler
|
|||||||
different_sources?(lock_sources, replacement_sources)
|
different_sources?(lock_sources, replacement_sources)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prefer_local!
|
||||||
|
all_sources.each(&:prefer_local!)
|
||||||
|
end
|
||||||
|
|
||||||
def local_only!
|
def local_only!
|
||||||
all_sources.each(&:local_only!)
|
all_sources.each(&:local_only!)
|
||||||
end
|
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}")
|
expect(out).to include("Using json #{default_json_version}")
|
||||||
end
|
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
|
it "caches remote and builtin gems" do
|
||||||
install_gemfile <<-G
|
install_gemfile <<-G
|
||||||
source "https://gem.repo2"
|
source "https://gem.repo2"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user