[rubygems/rubygems] Autoswitch to exact bundler version if present

https://github.com/rubygems/rubygems/commit/bb02953a97
This commit is contained in:
David Rodríguez 2019-01-07 12:00:35 +01:00 коммит произвёл Hiroshi SHIBATA
Родитель 3587824d71
Коммит 5998012a0c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F9CF13417264FAC2
3 изменённых файлов: 40 добавлений и 1 удалений

Просмотреть файл

@ -45,6 +45,11 @@ To install the missing version, run `gem install bundler:#{vr.first}`
return unless bundler_version = self.bundler_version
specs.reject! { |spec| spec.version.segments.first != bundler_version.segments.first }
exact_match_index = specs.find_index { |spec| spec.version == bundler_version }
return specs unless exact_match_index
specs.unshift(specs.delete_at(exact_match_index))
end
def self.bundle_update_bundler_version

Просмотреть файл

@ -341,6 +341,40 @@ class TestGem < Gem::TestCase
refute_includes e.message, "can't find gem bundler (>= 0.a) with executable bundle"
end
def test_activate_bin_path_selects_exact_bundler_version_if_present
bundler_latest = util_spec 'bundler', '2.0.1' do |s|
s.executables = ['bundle']
end
bundler_previous = util_spec 'bundler', '2.0.0' do |s|
s.executables = ['bundle']
end
install_specs bundler_latest, bundler_previous
File.open("Gemfile.lock", "w") do |f|
f.write <<-L.gsub(/ {8}/, "")
GEM
remote: https://rubygems.org/
specs:
PLATFORMS
ruby
DEPENDENCIES
BUNDLED WITH
2.0.0
L
end
File.open("Gemfile", "w") { |f| f.puts('source "https://rubygems.org"') }
load Gem.activate_bin_path("bundler", "bundle", ">= 0.a")
assert_equal %w(bundler-2.0.0), loaded_spec_names
end
def test_self_bin_path_no_exec_name
e = assert_raises ArgumentError do
Gem.bin_path 'a'

Просмотреть файл

@ -116,7 +116,7 @@ class TestGemBundlerVersionFinder < Gem::TestCase
assert_equal %w[1 1.0 1.0.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
end
bvf.stub(:bundler_version, v("2.a")) do
assert_equal %w[2 2.a 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
assert_equal %w[2.a 2 2.0 2.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)
end
bvf.stub(:bundler_version, v("3")) do
assert_equal %w[3 3.a 3.0 3.1.1], util_filter_specs(specs).map(&:version).map(&:to_s)