1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Merge RubyGems-3.2.5

This commit is contained in:
Hiroshi SHIBATA 2021-01-14 13:38:47 +09:00 committed by NARUSE, Yui
parent 93dcf0828d
commit 29777cb32a
6 changed files with 50 additions and 20 deletions

View file

@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
VERSION = "3.2.4".freeze
VERSION = "3.2.5".freeze
end
# Must be first since it unloads the prelude from 1.9.2

View file

@ -375,9 +375,7 @@ By default, this RubyGems will install gem as:
specs_dir = File.join(options[:destdir], specs_dir) unless Gem.win_platform?
mkdir_p specs_dir, :mode => 0755
bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
bundler_spec.files = Dir.chdir("bundler") { Dir["{*.md,{lib,exe}/**/*}"] }
bundler_spec.executables -= %w[bundler bundle_ruby]
bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
# Remove bundler-*.gemspec in default specification directory.
Dir.entries(specs_dir).

View file

@ -182,6 +182,7 @@ class Gem::Specification < Gem::BasicSpecification
@@default_value[k].nil?
end
@@stubs = nil
@@stubs_by_name = {}
# Sentinel object to represent "not found" stubs
@ -800,10 +801,8 @@ class Gem::Specification < Gem::BasicSpecification
def self.stubs
@@stubs ||= begin
pattern = "*.gemspec"
stubs = installed_stubs(dirs, pattern) + default_stubs(pattern)
stubs = stubs.uniq {|stub| stub.full_name }
stubs = stubs_for_pattern(pattern, false)
_resort!(stubs)
@@stubs_by_name = stubs.select {|s| Gem::Platform.match_spec? s }.group_by(&:name)
stubs
end
@ -820,26 +819,31 @@ class Gem::Specification < Gem::BasicSpecification
end
end
EMPTY = [].freeze # :nodoc:
##
# Returns a Gem::StubSpecification for installed gem named +name+
# only returns stubs that match Gem.platforms
def self.stubs_for(name)
if @@stubs_by_name[name]
@@stubs_by_name[name]
if @@stubs
@@stubs_by_name[name] || []
else
pattern = "#{name}-*.gemspec"
stubs = installed_stubs(dirs, pattern).select {|s| Gem::Platform.match_spec? s } + default_stubs(pattern)
stubs = stubs.uniq {|stub| stub.full_name }.group_by(&:name)
stubs.each_value {|v| _resort!(v) }
@@stubs_by_name.merge! stubs
@@stubs_by_name[name] ||= EMPTY
@@stubs_by_name[name] ||= stubs_for_pattern("#{name}-*.gemspec")
end
end
##
# Finds stub specifications matching a pattern from the standard locations,
# optionally filtering out specs not matching the current platform
#
def self.stubs_for_pattern(pattern, match_platform = true) # :nodoc:
installed_stubs = installed_stubs(Gem::Specification.dirs, pattern)
installed_stubs.select! {|s| Gem::Platform.match_spec? s } if match_platform
stubs = installed_stubs + default_stubs(pattern)
stubs = stubs.uniq {|stub| stub.full_name }
_resort!(stubs)
stubs
end
def self._resort!(specs) # :nodoc:
specs.sort! do |a, b|
names = a.name <=> b.name

View file

@ -26,7 +26,20 @@ begin
rescue LoadError
end
require 'bundler'
if File.exist?(bundler_gemspec)
require_relative '../../bundler/lib/bundler'
else
require 'bundler'
end
# Enable server plugin needed for bisection
if ENV["RG_BISECT_SERVER_PLUGIN"]
require ENV["RG_BISECT_SERVER_PLUGIN"]
Minitest.extensions << "server"
end
ENV["MT_NO_PLUGINS"] = "true"
require 'minitest/autorun'

View file

@ -24,6 +24,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
lib/rubygems/test_case.rb
lib/rubygems/ssl_certs/rubygems.org/foo.pem
bundler/exe/bundle
bundler/exe/bundler
bundler/lib/bundler.rb
bundler/lib/bundler/b.rb
bundler/bin/bundler/man/bundle-b.1
@ -41,7 +42,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
gemspec.name = "bundler"
gemspec.version = BUNDLER_VERS
gemspec.bindir = "exe"
gemspec.executables = ["bundle"]
gemspec.executables = ["bundle", "bundler"]
File.open 'bundler/bundler.gemspec', 'w' do |io|
io.puts gemspec.to_ruby
@ -135,6 +136,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
exec_line = out.shift until exec_line == "RubyGems installed the following executables:"
assert_equal "\t#{default_gem_bin_path}", out.shift
assert_equal "\t#{default_bundle_bin_path}", out.shift
assert_equal "\t#{default_bundler_bin_path}", out.shift
end
def test_env_shebang_flag
@ -152,6 +154,7 @@ class TestGemCommandsSetupCommand < Gem::TestCase
bin_env = win_platform? ? "" : %w[/usr/bin/env /bin/env].find {|f| File.executable?(f) } + " "
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_gem_bin_path)
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundle_bin_path)
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(default_bundler_bin_path)
assert_match %r{\A#!\s*#{bin_env}#{ruby_exec}}, File.read(gem_bin_path)
end
@ -387,4 +390,8 @@ class TestGemCommandsSetupCommand < Gem::TestCase
def default_bundle_bin_path
File.join @install_dir, 'bin', 'bundle'
end
def default_bundler_bin_path
File.join @install_dir, 'bin', 'bundler'
end
end unless Gem.java_platform?

View file

@ -1161,6 +1161,14 @@ dependencies: []
Gem::Specification.class_variable_set(:@@stubs, nil)
end
def test_self_stubs_for_no_lazy_loading_after_all_specs_setup
Gem::Specification.all = [util_spec('a', '1')]
save_gemspec('b-1', '1', File.join(Gem.dir, 'specifications')){|s| s.name = 'b' }
assert_equal [], Gem::Specification.stubs_for('b').map {|s| s.full_name }
end
def test_self_stubs_for_mult_platforms
# gems for two different platforms are installed with --user-install
# the correct one should be returned in the array