Merge RubyGems-3.3.2 and Bundler-2.3.2

This commit is contained in:
Hiroshi SHIBATA 2021-12-24 09:32:59 +09:00
Родитель de0523fedd
Коммит b0ad6cb371
12 изменённых файлов: 72 добавлений и 76 удалений

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

@ -292,10 +292,7 @@ module Bundler
locked_major = @locked_bundler_version.segments.first
current_major = Gem::Version.create(Bundler::VERSION).segments.first
if updating_major = locked_major < current_major
Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{current_major}, " \
"after which you will be unable to return to Bundler #{locked_major}."
end
updating_major = locked_major < current_major
end
preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))

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

@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
VERSION = "2.3.1".freeze
VERSION = "2.3.2".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i

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

@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
VERSION = "3.3.1".freeze
VERSION = "3.3.2".freeze
end
# Must be first since it unloads the prelude from 1.9.2
@ -163,16 +163,6 @@ module Gem
specifications/default
].freeze
##
# Exception classes used in a Gem.read_binary +rescue+ statement
READ_BINARY_ERRORS = [Errno::EACCES, Errno::EROFS, Errno::ENOSYS, Errno::ENOTSUP].freeze
##
# Exception classes used in Gem.write_binary +rescue+ statement
WRITE_BINARY_ERRORS = [Errno::ENOSYS, Errno::ENOTSUP].freeze
@@win_platform = nil
@configuration = nil
@ -776,40 +766,42 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Safely read a file in binary mode on all platforms.
def self.read_binary(path)
File.open path, 'rb+' do |f|
f.flock(File::LOCK_EX)
f.read
open_with_flock(path, 'rb+') do |io|
io.read
end
rescue *READ_BINARY_ERRORS
File.open path, 'rb' do |f|
f.read
end
rescue Errno::ENOLCK # NFS
if Thread.main != Thread.current
raise
else
File.open path, 'rb' do |f|
f.read
end
rescue Errno::EACCES, Errno::EROFS
open_with_flock(path, 'rb') do |io|
io.read
end
end
##
# Safely write a file in binary mode on all platforms.
def self.write_binary(path, data)
File.open(path, File::RDWR | File::CREAT | File::LOCK_EX, binmode: true) do |io|
open_with_flock(path, 'wb') do |io|
io.write data
end
rescue *WRITE_BINARY_ERRORS
File.open(path, 'wb') do |io|
io.write data
end
##
# Open a file with given flags, and protect access with flock
def self.open_with_flock(path, flags, &block)
File.open(path, flags) do |io|
unless java_platform?
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOSYS, Errno::ENOTSUP
end
end
yield io
end
rescue Errno::ENOLCK # NFS
if Thread.main != Thread.current
raise
else
File.open(path, 'wb') do |io|
io.write data
File.open(path, flags) do |io|
yield io
end
end
end

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

@ -24,10 +24,14 @@ class Gem::UnknownCommandError < Gem::Exception
return if defined?(@attached)
if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
DidYouMean::SPELL_CHECKERS['Gem::UnknownCommandError'] =
Gem::UnknownCommandSpellChecker
if DidYouMean.respond_to?(:correct_error)
DidYouMean.correct_error(Gem::UnknownCommandError, Gem::UnknownCommandSpellChecker)
else
DidYouMean::SPELL_CHECKERS['Gem::UnknownCommandError'] =
Gem::UnknownCommandSpellChecker
prepend DidYouMean::Correctable
prepend DidYouMean::Correctable
end
end
@attached = true

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

@ -1116,7 +1116,7 @@ class Gem::Specification < Gem::BasicSpecification
file = file.dup.tap(&Gem::UNTAINT)
return unless File.file?(file)
code = File.read file, :mode => 'r:UTF-8:-'
code = Gem.open_with_flock(file, 'r:UTF-8:-', &:read)
code.tap(&Gem::UNTAINT)

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

@ -110,7 +110,7 @@ class Gem::StubSpecification < Gem::BasicSpecification
begin
saved_lineno = $.
File.open loaded_from, OPEN_MODE do |file|
Gem.open_with_flock loaded_from, OPEN_MODE do |file|
begin
file.readline # discard encoding line
stubline = file.readline.chomp

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

@ -225,7 +225,7 @@ RSpec.describe "the lockfile format" do
G
end
it "warns when updating bundler major version" do
it "update the bundler major version just fine" do
current_version = Bundler::VERSION
older_major = previous_major(current_version)
@ -253,10 +253,7 @@ RSpec.describe "the lockfile format" do
gem "rack"
G
expect(err).to include(
"Warning: the lockfile is being updated to Bundler " \
"#{current_version.split(".").first}, after which you will be unable to return to Bundler #{older_major.split(".").first}."
)
expect(err).to be_empty
expect(lockfile).to eq <<~G
GEM

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

@ -782,6 +782,39 @@ ERROR: Possible alternatives: non_existent_with_hint
assert_match "1 gem installed", @ui.output
end
def test_execute_remote_truncates_existing_gemspecs
spec_fetcher do |fetcher|
fetcher.gem 'a', 1
end
@cmd.options[:domain] = :remote
@cmd.options[:args] = %w[a]
use_ui @ui do
assert_raise Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
end
assert_equal %w[a-1], @cmd.installed_specs.map {|spec| spec.full_name }
assert_match "1 gem installed", @ui.output
a1_gemspec = File.join(@gemhome, 'specifications', "a-1.gemspec")
initial_a1_gemspec_content = File.read(a1_gemspec)
modified_a1_gemspec_content = initial_a1_gemspec_content + "\n # AAAAAAA\n"
File.write(a1_gemspec, modified_a1_gemspec_content)
use_ui @ui do
assert_raise Gem::MockGemUi::SystemExitException, @ui.error do
@cmd.execute
end
end
assert_equal initial_a1_gemspec_content, File.read(a1_gemspec)
end
def test_execute_remote_ignores_files
specs = spec_fetcher do |fetcher|
fetcher.gem 'a', 1

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

@ -288,33 +288,6 @@ gem 'other', version
"(SyntaxError)", e.message
end
def test_ensure_no_race_conditions_between_installing_and_loading_gemspecs
a, a_gem = util_gem 'a', 2
Gem::Installer.at(a_gem).install
t1 = Thread.new do
5.times do
Gem::Installer.at(a_gem).install
sleep 0.1
end
end
t2 = Thread.new do
_, err = capture_output do
20.times do
Gem::Specification.load(a.spec_file)
Gem::Specification.send(:clear_load_cache)
end
end
assert_empty err
end
t1.join
t2.join
end
def test_ensure_loadable_spec_security_policy
pend 'openssl is missing' unless Gem::HAVE_OPENSSL

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

@ -60,4 +60,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
2.3.1
2.3.2

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

@ -66,4 +66,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
2.3.1
2.3.2

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

@ -41,4 +41,4 @@ DEPENDENCIES
webrick (= 1.7.0)
BUNDLED WITH
2.3.1
2.3.2