Skip to content

Commit 494fcc5

Browse files
hsbtk0kubun
authored andcommitted
Merge RubyGems-3.5.22 and Bundler-2.5.22
1 parent d03e422 commit 494fcc5

39 files changed

+371
-202
lines changed

lib/bundler/dsl.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,21 +589,21 @@ def to_s
589589

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

595595
lines = contents.lines.to_a
596596
indent = " # "
597597
indicator = indent.tr("#", ">")
598-
first_line = line_numer.zero?
599-
last_line = (line_numer == (lines.count - 1))
598+
first_line = line_number.zero?
599+
last_line = (line_number == (lines.count - 1))
600600

601601
m << "\n"
602602
m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n"
603603
m << "#{indent}-------------------------------------------\n"
604-
m << "#{indent}#{lines[line_numer - 1]}" unless first_line
605-
m << "#{indicator}#{lines[line_numer]}"
606-
m << "#{indent}#{lines[line_numer + 1]}" unless last_line
604+
m << "#{indent}#{lines[line_number - 1]}" unless first_line
605+
m << "#{indicator}#{lines[line_number]}"
606+
m << "#{indent}#{lines[line_number + 1]}" unless last_line
607607
m << "\n" unless m.end_with?("\n")
608608
m << "#{indent}-------------------------------------------\n"
609609
end

lib/bundler/installer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def load_plugins
221221

222222
requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
223223
path_plugin_files = requested_path_gems.map do |spec|
224-
Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
224+
spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
225225
rescue TypeError
226226
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
227227
raise Gem::InvalidSpecificationException, error_message

lib/bundler/plugin/api/source.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def specs
131131
Bundler::Index.build do |index|
132132
files.each do |file|
133133
next unless spec = Bundler.load_gemspec(file)
134-
Bundler.rubygems.set_installed_by_version(spec)
134+
spec.installed_by_version = Gem::VERSION
135135

136136
spec.source = self
137137
Bundler.rubygems.validate(spec)

lib/bundler/rubygems_ext.rb

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ class << self
3636
remove_method :open_file_with_flock if Gem.respond_to?(:open_file_with_flock)
3737

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

4243
File.open(path, mode) do |io|
4344
begin
4445
io.flock(File::LOCK_EX)
4546
rescue Errno::ENOSYS, Errno::ENOTSUP
46-
rescue Errno::ENOLCK # NFS
47-
raise unless Thread.main == Thread.current
4847
end
4948
yield io
5049
end
@@ -267,6 +266,16 @@ def to_lock
267266
end
268267
out
269268
end
269+
270+
if Gem.rubygems_version < Gem::Version.new("3.5.22")
271+
module FilterIgnoredSpecs
272+
def matching_specs(platform_only = false)
273+
super.reject(&:ignored?)
274+
end
275+
end
276+
277+
prepend FilterIgnoredSpecs
278+
end
270279
end
271280

272281
# Requirements using lambda operator differentiate trailing zeros since rubygems 3.2.6
@@ -389,6 +398,15 @@ def extensions_dir
389398
end
390399
end
391400
end
401+
402+
# Can be removed once RubyGems 3.5.22 support is dropped
403+
unless new.respond_to?(:ignored?)
404+
def ignored?
405+
return @ignored unless @ignored.nil?
406+
407+
@ignored = missing_extensions?
408+
end
409+
end
392410
end
393411

394412
require "rubygems/name_tuple"

lib/bundler/rubygems_integration.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,28 +57,6 @@ def validate(spec)
5757
nil
5858
end
5959

60-
def set_installed_by_version(spec, installed_by_version = Gem::VERSION)
61-
return unless spec.respond_to?(:installed_by_version=)
62-
spec.installed_by_version = Gem::Version.create(installed_by_version)
63-
end
64-
65-
def spec_missing_extensions?(spec, default = true)
66-
return spec.missing_extensions? if spec.respond_to?(:missing_extensions?)
67-
68-
return false if spec.default_gem?
69-
return false if spec.extensions.empty?
70-
71-
default
72-
end
73-
74-
def spec_matches_for_glob(spec, glob)
75-
return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
76-
77-
spec.load_paths.flat_map do |lp|
78-
Dir["#{lp}/#{glob}#{suffix_pattern}"]
79-
end
80-
end
81-
8260
def stub_set_spec(stub, spec)
8361
stub.instance_variable_set(:@spec, spec)
8462
end

lib/bundler/source/git.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def install(spec, options = {})
210210
checkout
211211
end
212212

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

216216
requires_checkout? ? spec.post_install_message : nil
@@ -299,7 +299,7 @@ def serialize_gemspecs_in(destination)
299299
# The gemspecs we cache should already be evaluated.
300300
spec = Bundler.load_gemspec(spec_path)
301301
next unless spec
302-
Bundler.rubygems.set_installed_by_version(spec)
302+
spec.installed_by_version = Gem::VERSION
303303
Bundler.rubygems.validate(spec)
304304
File.open(spec_path, "wb") {|file| file.write(spec.to_ruby) }
305305
end

lib/bundler/source/path.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def has_app_cache?
150150

151151
def load_gemspec(file)
152152
return unless spec = Bundler.load_gemspec(file)
153-
Bundler.rubygems.set_installed_by_version(spec)
153+
spec.installed_by_version = Gem::VERSION
154154
spec
155155
end
156156

lib/bundler/source/rubygems.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,7 @@ def installed_specs
357357
@installed_specs ||= Index.build do |idx|
358358
Bundler.rubygems.installed_specs.reverse_each do |spec|
359359
spec.source = self
360-
if Bundler.rubygems.spec_missing_extensions?(spec, false)
361-
Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions"
362-
next
363-
end
360+
next if spec.ignored?
364361
idx << spec
365362
end
366363
end

lib/bundler/stub_specification.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ def to_yaml
2828

2929
# @!group Stub Delegates
3030

31+
def ignored?
32+
return @ignored unless @ignored.nil?
33+
34+
@ignored = missing_extensions?
35+
return false unless @ignored
36+
37+
warn "Source #{source} is ignoring #{self} because it is missing extensions"
38+
39+
true
40+
end
41+
3142
def manually_installed?
3243
# This is for manually installed gems which are gems that were fixed in place after a
3344
# failed installation. Once the issue was resolved, the user then manually created

lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
# #verify_callback :: For server certificate verification
6969
# #verify_depth :: Depth of certificate verification
7070
# #verify_mode :: How connections should be verified
71+
# #verify_hostname :: Use hostname verification for server certificate
72+
# during the handshake
7173
#
7274
# == Proxies
7375
#
@@ -174,7 +176,7 @@ class Gem::Net::HTTP::Persistent
174176
##
175177
# The version of Gem::Net::HTTP::Persistent you are using
176178

177-
VERSION = '4.0.2'
179+
VERSION = '4.0.4'
178180

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

450452
attr_reader :verify_mode
451453

454+
##
455+
# HTTPS verify_hostname.
456+
#
457+
# If a client sets this to true and enables SNI with SSLSocket#hostname=,
458+
# the hostname verification on the server certificate is performed
459+
# automatically during the handshake using
460+
# OpenSSL::SSL.verify_certificate_identity().
461+
#
462+
# You can set +verify_hostname+ as true to use hostname verification
463+
# during the handshake.
464+
#
465+
# NOTE: This works with Ruby > 3.0.
466+
467+
attr_reader :verify_hostname
468+
452469
##
453470
# Creates a new Gem::Net::HTTP::Persistent.
454471
#
@@ -508,6 +525,7 @@ def initialize name: nil, proxy: nil, pool_size: DEFAULT_POOL_SIZE
508525
@verify_callback = nil
509526
@verify_depth = nil
510527
@verify_mode = nil
528+
@verify_hostname = nil
511529
@cert_store = nil
512530

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

608626
return yield connection
609627
rescue Errno::ECONNREFUSED
610-
address = http.proxy_address || http.address
611-
port = http.proxy_port || http.port
628+
if http.proxy?
629+
address = http.proxy_address
630+
port = http.proxy_port
631+
else
632+
address = http.address
633+
port = http.port
634+
end
612635

613636
raise Error, "connection refused: #{address}:#{port}"
614637
rescue Errno::EHOSTDOWN
615-
address = http.proxy_address || http.address
616-
port = http.proxy_port || http.port
638+
if http.proxy?
639+
address = http.proxy_address
640+
port = http.proxy_port
641+
else
642+
address = http.address
643+
port = http.port
644+
end
617645

618646
raise Error, "host down: #{address}:#{port}"
619647
ensure
@@ -948,8 +976,10 @@ def ssl connection
948976
connection.min_version = @min_version if @min_version
949977
connection.max_version = @max_version if @max_version
950978

951-
connection.verify_depth = @verify_depth
952-
connection.verify_mode = @verify_mode
979+
connection.verify_depth = @verify_depth
980+
connection.verify_mode = @verify_mode
981+
connection.verify_hostname = @verify_hostname if
982+
@verify_hostname != nil && connection.respond_to?(:verify_hostname=)
953983

954984
if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
955985
not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
@@ -1058,6 +1088,15 @@ def verify_mode= verify_mode
10581088
reconnect_ssl
10591089
end
10601090

1091+
##
1092+
# Sets the HTTPS verify_hostname.
1093+
1094+
def verify_hostname= verify_hostname
1095+
@verify_hostname = verify_hostname
1096+
1097+
reconnect_ssl
1098+
end
1099+
10611100
##
10621101
# SSL verification callback.
10631102

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

10711110
require_relative 'persistent/connection'
10721111
require_relative 'persistent/pool'
1073-

0 commit comments

Comments
 (0)