[rubygems/rubygems] restart with BUNDLE_VERSION if it's specified

https://github.com/rubygems/rubygems/commit/57cfe7cf8d
This commit is contained in:
Hiroshi SHIBATA 2023-07-12 16:29:48 +09:00
Родитель f16c880f77
Коммит d3305cab44
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F9CF13417264FAC2
2 изменённых файлов: 19 добавлений и 13 удалений

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

@ -9,26 +9,20 @@ module Bundler
def restart_with_locked_bundler_if_needed
return unless needs_switching? && installed?
restart_with(lockfile_version)
restart_with(restart_version)
end
def install_locked_bundler_and_restart_with_it_if_needed
return unless needs_switching?
begin
# BUNDLE_VERSION=x.y.z
restart_version = Gem::Version.new(Bundler.settings[:version])
if restart_version == lockfile_version
Bundler.ui.info \
"Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
"Installing Bundler #{lockfile_version} and restarting using that version."
else
Bundler.ui.info \
"Bundler #{current_version} is running, but your configuration was #{restart_version}. " \
"Installing Bundler #{restart_version} and restarting using that version."
rescue ArgumentError
# BUNDLE_VERSION=local
restart_version = lockfile_version
Bundler.ui.info \
"Bundler #{current_version} is running, but your lockfile was generated with #{restart_version}. " \
"Installing Bundler #{restart_version} and restarting using that version."
end
install_and_restart_with(restart_version)
@ -164,7 +158,7 @@ module Bundler
def installed?
Bundler.configure
Bundler.rubygems.find_bundler(lockfile_version.to_s)
Bundler.rubygems.find_bundler(restart_version.to_s)
end
def current_version
@ -177,5 +171,14 @@ module Bundler
parsed_version = Bundler::LockfileParser.bundled_with
@lockfile_version = parsed_version ? Gem::Version.new(parsed_version) : nil
end
def restart_version
return @restart_version if defined?(@restart_version)
# BUNDLE_VERSION=x.y.z
@restart_version = Gem::Version.new(Bundler.settings[:version])
rescue ArgumentError
# BUNDLE_VERSION=local
@restart_version = lockfile_version
end
end
end

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

@ -109,6 +109,9 @@ RSpec.describe "Self management", :rubygems => ">= 3.3.0.dev", :realworld => tru
bundle "config set --local version #{previous_minor}"
bundle "install", :artifice => "vcr"
expect(out).to include("Bundler #{Bundler::VERSION} is running, but your configuration was #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.")
bundle "-v"
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{previous_minor}" : previous_minor)
end
it "does not try to install when using bundle config version global" do