Skip to content

Commit

Permalink
Merge RubyGems-3.5.22 and Bundler-2.5.22
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt authored and k0kubun committed Oct 17, 2024
1 parent d03e422 commit 494fcc5
Show file tree
Hide file tree
Showing 39 changed files with 371 additions and 202 deletions.
14 changes: 7 additions & 7 deletions lib/bundler/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -589,21 +589,21 @@ def to_s

trace_line = backtrace.find {|l| l.include?(dsl_path) } || trace_line
return m unless trace_line
line_numer = trace_line.split(":")[1].to_i - 1
return m unless line_numer
line_number = trace_line.split(":")[1].to_i - 1
return m unless line_number

lines = contents.lines.to_a
indent = " # "
indicator = indent.tr("#", ">")
first_line = line_numer.zero?
last_line = (line_numer == (lines.count - 1))
first_line = line_number.zero?
last_line = (line_number == (lines.count - 1))

m << "\n"
m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n"
m << "#{indent}-------------------------------------------\n"
m << "#{indent}#{lines[line_numer - 1]}" unless first_line
m << "#{indicator}#{lines[line_numer]}"
m << "#{indent}#{lines[line_numer + 1]}" unless last_line
m << "#{indent}#{lines[line_number - 1]}" unless first_line
m << "#{indicator}#{lines[line_number]}"
m << "#{indent}#{lines[line_number + 1]}" unless last_line
m << "\n" unless m.end_with?("\n")
m << "#{indent}-------------------------------------------\n"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def load_plugins

requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
path_plugin_files = requested_path_gems.map do |spec|
Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/plugin/api/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def specs
Bundler::Index.build do |index|
files.each do |file|
next unless spec = Bundler.load_gemspec(file)
Bundler.rubygems.set_installed_by_version(spec)
spec.installed_by_version = Gem::VERSION

spec.source = self
Bundler.rubygems.validate(spec)
Expand Down
24 changes: 21 additions & 3 deletions lib/bundler/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ class << self
remove_method :open_file_with_flock if Gem.respond_to?(:open_file_with_flock)

def open_file_with_flock(path, &block)
mode = IO::RDONLY | IO::APPEND | IO::CREAT | IO::BINARY
# read-write mode is used rather than read-only in order to support NFS
mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)

File.open(path, mode) do |io|
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOSYS, Errno::ENOTSUP
rescue Errno::ENOLCK # NFS
raise unless Thread.main == Thread.current
end
yield io
end
Expand Down Expand Up @@ -267,6 +266,16 @@ def to_lock
end
out
end

if Gem.rubygems_version < Gem::Version.new("3.5.22")
module FilterIgnoredSpecs
def matching_specs(platform_only = false)
super.reject(&:ignored?)
end
end

prepend FilterIgnoredSpecs
end
end

# Requirements using lambda operator differentiate trailing zeros since rubygems 3.2.6
Expand Down Expand Up @@ -389,6 +398,15 @@ def extensions_dir
end
end
end

# Can be removed once RubyGems 3.5.22 support is dropped
unless new.respond_to?(:ignored?)
def ignored?
return @ignored unless @ignored.nil?

@ignored = missing_extensions?
end
end
end

require "rubygems/name_tuple"
Expand Down
22 changes: 0 additions & 22 deletions lib/bundler/rubygems_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,6 @@ def validate(spec)
nil
end

def set_installed_by_version(spec, installed_by_version = Gem::VERSION)
return unless spec.respond_to?(:installed_by_version=)
spec.installed_by_version = Gem::Version.create(installed_by_version)
end

def spec_missing_extensions?(spec, default = true)
return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)

return false if spec.default_gem?
return false if spec.extensions.empty?

default
end

def spec_matches_for_glob(spec, glob)
return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)

spec.load_paths.flat_map do |lp|
Dir["#{lp}/#{glob}#{suffix_pattern}"]
end
end

def stub_set_spec(stub, spec)
stub.instance_variable_set(:@spec, spec)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def install(spec, options = {})
checkout
end

generate_bin_options = { disable_extensions: !Bundler.rubygems.spec_missing_extensions?(spec), build_args: options[:build_args] }
generate_bin_options = { disable_extensions: !spec.missing_extensions?, build_args: options[:build_args] }
generate_bin(spec, generate_bin_options)

requires_checkout? ? spec.post_install_message : nil
Expand Down Expand Up @@ -299,7 +299,7 @@ def serialize_gemspecs_in(destination)
# The gemspecs we cache should already be evaluated.
spec = Bundler.load_gemspec(spec_path)
next unless spec
Bundler.rubygems.set_installed_by_version(spec)
spec.installed_by_version = Gem::VERSION
Bundler.rubygems.validate(spec)
File.open(spec_path, "wb") {|file| file.write(spec.to_ruby) }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/source/path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def has_app_cache?

def load_gemspec(file)
return unless spec = Bundler.load_gemspec(file)
Bundler.rubygems.set_installed_by_version(spec)
spec.installed_by_version = Gem::VERSION
spec
end

Expand Down
5 changes: 1 addition & 4 deletions lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,7 @@ def installed_specs
@installed_specs ||= Index.build do |idx|
Bundler.rubygems.installed_specs.reverse_each do |spec|
spec.source = self
if Bundler.rubygems.spec_missing_extensions?(spec, false)
Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions"
next
end
next if spec.ignored?
idx << spec
end
end
Expand Down
11 changes: 11 additions & 0 deletions lib/bundler/stub_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ def to_yaml

# @!group Stub Delegates

def ignored?
return @ignored unless @ignored.nil?

@ignored = missing_extensions?
return false unless @ignored

warn "Source #{source} is ignoring #{self} because it is missing extensions"

true
end

def manually_installed?
# This is for manually installed gems which are gems that were fixed in place after a
# failed installation. Once the issue was resolved, the user then manually created
Expand Down
54 changes: 46 additions & 8 deletions lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
# #verify_callback :: For server certificate verification
# #verify_depth :: Depth of certificate verification
# #verify_mode :: How connections should be verified
# #verify_hostname :: Use hostname verification for server certificate
# during the handshake
#
# == Proxies
#
Expand Down Expand Up @@ -174,7 +176,7 @@ class Gem::Net::HTTP::Persistent
##
# The version of Gem::Net::HTTP::Persistent you are using

VERSION = '4.0.2'
VERSION = '4.0.4'

##
# Error class for errors raised by Gem::Net::HTTP::Persistent. Various
Expand Down Expand Up @@ -449,6 +451,21 @@ def self.detect_idle_timeout uri, max = 10

attr_reader :verify_mode

##
# HTTPS verify_hostname.
#
# If a client sets this to true and enables SNI with SSLSocket#hostname=,
# the hostname verification on the server certificate is performed
# automatically during the handshake using
# OpenSSL::SSL.verify_certificate_identity().
#
# You can set +verify_hostname+ as true to use hostname verification
# during the handshake.
#
# NOTE: This works with Ruby > 3.0.

attr_reader :verify_hostname

##
# Creates a new Gem::Net::HTTP::Persistent.
#
Expand Down Expand Up @@ -508,6 +525,7 @@ def initialize name: nil, proxy: nil, pool_size: DEFAULT_POOL_SIZE
@verify_callback = nil
@verify_depth = nil
@verify_mode = nil
@verify_hostname = nil
@cert_store = nil

@generation = 0 # incremented when proxy Gem::URI changes
Expand Down Expand Up @@ -607,13 +625,23 @@ def connection_for uri

return yield connection
rescue Errno::ECONNREFUSED
address = http.proxy_address || http.address
port = http.proxy_port || http.port
if http.proxy?
address = http.proxy_address
port = http.proxy_port
else
address = http.address
port = http.port
end

raise Error, "connection refused: #{address}:#{port}"
rescue Errno::EHOSTDOWN
address = http.proxy_address || http.address
port = http.proxy_port || http.port
if http.proxy?
address = http.proxy_address
port = http.proxy_port
else
address = http.address
port = http.port
end

raise Error, "host down: #{address}:#{port}"
ensure
Expand Down Expand Up @@ -948,8 +976,10 @@ def ssl connection
connection.min_version = @min_version if @min_version
connection.max_version = @max_version if @max_version

connection.verify_depth = @verify_depth
connection.verify_mode = @verify_mode
connection.verify_depth = @verify_depth
connection.verify_mode = @verify_mode
connection.verify_hostname = @verify_hostname if
@verify_hostname != nil && connection.respond_to?(:verify_hostname=)

if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
Expand Down Expand Up @@ -1058,6 +1088,15 @@ def verify_mode= verify_mode
reconnect_ssl
end

##
# Sets the HTTPS verify_hostname.

def verify_hostname= verify_hostname
@verify_hostname = verify_hostname

reconnect_ssl
end

##
# SSL verification callback.

Expand All @@ -1070,4 +1109,3 @@ def verify_callback= callback

require_relative 'persistent/connection'
require_relative 'persistent/pool'

2 changes: 2 additions & 0 deletions lib/bundler/vendor/uri/lib/uri/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module Bundler::URI
Parser = RFC2396_Parser
RFC3986_PARSER = RFC3986_Parser.new
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
RFC2396_PARSER = RFC2396_Parser.new
Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)

# Bundler::URI::Parser.new
DEFAULT_PARSER = Parser.new
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/vendor/uri/lib/uri/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Bundler::URI
# :stopdoc:
VERSION_CODE = '001300'.freeze
VERSION_CODE = '001301'.freeze
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
# :startdoc:
end
2 changes: 1 addition & 1 deletion lib/bundler/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: false

module Bundler
VERSION = "2.5.21".freeze
VERSION = "2.5.22".freeze

def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
Expand Down
7 changes: 3 additions & 4 deletions lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require "rbconfig"

module Gem
VERSION = "3.5.21"
VERSION = "3.5.22"
end

# Must be first since it unloads the prelude from 1.9.2
Expand Down Expand Up @@ -788,15 +788,14 @@ def self.open_file_with_lock(path, &block)
# Open a file with given flags, and protect access with flock

def self.open_file_with_flock(path, &block)
mode = IO::RDONLY | IO::APPEND | IO::CREAT | IO::BINARY
# read-write mode is used rather than read-only in order to support NFS
mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)

File.open(path, mode) do |io|
begin
io.flock(File::LOCK_EX)
rescue Errno::ENOSYS, Errno::ENOTSUP
rescue Errno::ENOLCK # NFS
raise unless Thread.main == Thread.current
end
yield io
end
Expand Down
17 changes: 11 additions & 6 deletions lib/rubygems/basic_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ def base_dir
# Return true if this spec can require +file+.

def contains_requirable_file?(file)
if @ignored
return false
elsif missing_extensions?
@ignored = true

if ignored?
if platform == Gem::Platform::RUBY || Gem::Platform.local === platform
warn "Ignoring #{full_name} because its extensions are not built. " \
"Try: gem pristine #{name} --version #{version}"
Expand All @@ -93,8 +89,17 @@ def contains_requirable_file?(file)
end
end

##
# Return true if this spec should be ignored because it's missing extensions.

def ignored?
return @ignored unless @ignored.nil?

@ignored = missing_extensions?
end

def default_gem?
loaded_from &&
!loaded_from.nil? &&
File.dirname(loaded_from) == Gem.default_specifications_dir
end

Expand Down
9 changes: 7 additions & 2 deletions lib/rubygems/command_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,14 @@ def load_and_instantiate(command_name)
const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase } << "Command"

begin
require "rubygems/commands/#{command_name}_command"
begin
require "rubygems/commands/#{command_name}_command"
rescue LoadError
# it may have been defined from a rubygems_plugin.rb file
end

Gem::Commands.const_get(const_name).new
rescue StandardError, LoadError => e
rescue StandardError => e
alert_error clean_text("Loading command: #{command_name} (#{e.class})\n\t#{e}")
ui.backtrace e
end
Expand Down
Loading

0 comments on commit 494fcc5

Please sign in to comment.