ruby-changes:55208
From: hsbt <ko1@a...>
Date: Tue, 2 Apr 2019 20:48:25 +0900 (JST)
Subject: [ruby-changes:55208] hsbt:r67415 (trunk): Merge rubygems/rubygems from upstream.
hsbt 2019-04-02 20:48:18 +0900 (Tue, 02 Apr 2019) New Revision: 67415 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67415 Log: Merge rubygems/rubygems from upstream. The current master branch is https://github.com/rubygems/rubygems/commit/97b264f0fa248c864b6ee9a23d3ff1cdd217dddb Modified files: trunk/lib/rubygems/basic_specification.rb trunk/lib/rubygems/command.rb trunk/lib/rubygems/commands/cert_command.rb trunk/lib/rubygems/commands/pristine_command.rb trunk/lib/rubygems/commands/setup_command.rb trunk/lib/rubygems/commands/uninstall_command.rb trunk/lib/rubygems/dependency_installer.rb trunk/lib/rubygems/gemcutter_utilities.rb trunk/lib/rubygems/installer.rb trunk/lib/rubygems/package.rb trunk/lib/rubygems/spec_fetcher.rb trunk/lib/rubygems/specification.rb trunk/lib/rubygems/test_case.rb trunk/lib/rubygems.rb trunk/test/rubygems/test_gem.rb trunk/test/rubygems/test_gem_commands_install_command.rb trunk/test/rubygems/test_gem_commands_owner_command.rb trunk/test/rubygems/test_gem_commands_pristine_command.rb trunk/test/rubygems/test_gem_commands_push_command.rb trunk/test/rubygems/test_gem_commands_setup_command.rb trunk/test/rubygems/test_gem_commands_uninstall_command.rb trunk/test/rubygems/test_gem_commands_yank_command.rb trunk/test/rubygems/test_gem_dependency.rb trunk/test/rubygems/test_gem_dependency_installer.rb trunk/test/rubygems/test_gem_indexer.rb trunk/test/rubygems/test_gem_installer.rb trunk/test/rubygems/test_gem_package.rb trunk/test/rubygems/test_gem_package_tar_writer.rb trunk/test/rubygems/test_gem_request_set_lockfile_parser.rb trunk/test/rubygems/test_gem_resolver.rb trunk/test/rubygems/test_gem_resolver_installed_specification.rb trunk/test/rubygems/test_gem_server.rb trunk/test/rubygems/test_gem_stub_specification.rb trunk/test/rubygems/test_require.rb Index: lib/rubygems/specification.rb =================================================================== --- lib/rubygems/specification.rb (revision 67414) +++ lib/rubygems/specification.rb (revision 67415) @@ -6,7 +6,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L6 # See LICENSE.txt for permissions. #++ - require 'rubygems/version' require 'rubygems/requirement' require 'rubygems/platform' @@ -18,7 +17,7 @@ require 'rubygems/util/list' https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L17 require 'stringio' ## -# The Specification class contains the information for a Gem. Typically +# The Specification class contains the information for a gem. Typically # defined in a .gemspec file or a Rakefile, and looks like this: # # Gem::Specification.new do |s| @@ -364,8 +363,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L363 ## # The metadata holds extra data for this gem that may be useful to other - # consumers and is settable by gem authors without requiring an update to - # the rubygems software. + # consumers and is settable by gem authors. # # Metadata items have the following restrictions: # @@ -775,15 +773,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L773 end private_class_method :gemspec_stubs_in - def self.default_stubs(pattern) - base_dir = Gem.default_dir - gems_dir = File.join base_dir, "gems" - gemspec_stubs_in(default_specifications_dir, pattern) do |path| - Gem::StubSpecification.default_gemspec_stub(path, base_dir, gems_dir) - end - end - private_class_method :default_stubs - def self.installed_stubs(dirs, pattern) map_stubs(dirs, pattern) do |path, base_dir, gems_dir| Gem::StubSpecification.gemspec_stub(path, base_dir, gems_dir) @@ -832,6 +821,17 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L821 end end + ## + # Returns a Gem::StubSpecification for default gems + + def self.default_stubs(pattern = "*.gemspec") + base_dir = Gem.default_dir + gems_dir = File.join base_dir, "gems" + gemspec_stubs_in(default_specifications_dir, pattern) do |path| + Gem::StubSpecification.default_gemspec_stub(path, base_dir, gems_dir) + end + end + EMPTY = [].freeze # :nodoc: ## @@ -873,51 +873,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L873 end ## - # Adds +spec+ to the known specifications, keeping the collection - # properly sorted. - - def self.add_spec(spec) - warn "Gem::Specification.add_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip - # TODO: find all extraneous adds - # puts - # p :add_spec => [spec.full_name, caller.reject { |s| s =~ /minitest/ }] - - # TODO: flush the rest of the crap from the tests - # raise "no dupes #{spec.full_name} in #{all_names.inspect}" if - # _all.include? spec - - raise "nil spec!" unless spec # TODO: remove once we're happy with tests - - return if _all.include? spec - - _all << spec - stubs << spec - (@@stubs_by_name[spec.name] ||= []) << spec - sort_by!(@@stubs_by_name[spec.name]) { |s| s.version } - _resort!(_all) - _resort!(stubs) - end - - ## - # Adds multiple specs to the known specifications. - - def self.add_specs(*specs) - warn "Gem::Specification.add_specs is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip - - raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy - - # TODO: this is much more efficient, but we need the extra checks for now - # _all.concat specs - # _resort! - - Gem::Deprecate.skip_during do - specs.each do |spec| # TODO: slow - add_spec spec - end - end - end - - ## # Returns all specifications. This method is discouraged from use. # You probably want to use one of the Enumerable methods instead. @@ -1245,17 +1200,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1200 end ## - # Removes +spec+ from the known specs. - - def self.remove_spec(spec) - warn "Gem::Specification.remove_spec is deprecated and will be removed in RubyGems 3.0" unless Gem::Deprecate.skip - _all.delete spec - stubs.delete_if { |s| s.full_name == spec.full_name } - (@@stubs_by_name[spec.name] || []).delete_if { |s| s.full_name == spec.full_name } - reset - end - - ## # Is +name+ a required attribute? def self.required_attribute?(name) @@ -2029,8 +1973,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1973 yaml_initialize coder.tag, coder.map end - - eval <<-RB, binding, __FILE__, __LINE__ + 1 def set_nil_attributes_to_nil #{@@nil_attributes.map {|key| "@#{key} = nil" }.join "; "} Index: lib/rubygems/dependency_installer.rb =================================================================== --- lib/rubygems/dependency_installer.rb (revision 67414) +++ lib/rubygems/dependency_installer.rb (revision 67415) @@ -143,7 +143,9 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L143 end end - results = find_gems_with_sources(dep) + results = Gem::Deprecate.skip_during do + find_gems_with_sources(dep) + end results.sorted.each do |t| to_do.push t.spec @@ -166,15 +168,20 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L168 def available_set_for(dep_or_name, version) # :nodoc: if String === dep_or_name - find_spec_by_name_and_version dep_or_name, version, @prerelease + Gem::Deprecate.skip_during do + find_spec_by_name_and_version dep_or_name, version, @prerelease + end else dep = dep_or_name.dup dep.prerelease = @prerelease - @available = find_gems_with_sources dep + @available = Gem::Deprecate.skip_during do + find_gems_with_sources dep + end end @available.pick_best! end + deprecate :available_set_for, :none, 2019, 12 ## # Indicated, based on the requested domain, if local @@ -266,6 +273,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L273 set end + deprecate :find_gems_with_sources, :none, 2019, 12 ## # Finds a spec and the source_uri it came from for gem +gem_name+ and @@ -302,7 +310,10 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L310 dep = Gem::Dependency.new gem_name, version dep.prerelease = true if prerelease - set = find_gems_with_sources(dep, true) + set = Gem::Deprecate.skip_during do + find_gems_with_sources(dep, true) + end + set.match_platform! end @@ -312,6 +323,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L323 @available = set end + deprecate :find_spec_by_name_and_version, :none, 2019, 12 ## # Gathers all dependencies necessary for the installation from local and @@ -332,7 +344,10 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L344 dependency_list = Gem::DependencyList.new @development dependency_list.add(*specs) to_do = specs.dup - add_found_dependencies to_do, dependency_list unless @ignore_dependencies + + Gem::Deprecate.skip_during do + add_found_dependencies to_do, dependency_list unless @ignore_dependencies + end # REFACTOR maybe abstract away using Gem::Specification.include? so # that this isn't dependent only on the currently installed gems Index: lib/rubygems/commands/uninstall_command.rb =================================================================== --- lib/rubygems/commands/uninstall_command.rb (revision 67414) +++ lib/rubygems/commands/uninstall_command.rb (revision 67415) @@ -148,10 +148,13 @@ that is a dependency of an existing gem. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/uninstall_command.rb#L148 def uninstall_specific deplist = Gem::DependencyList.new + original_gem_version = {} get_all_gem_names_and_versions.each do |name, version| - requirement = Array(version || options[:version]) - gem_specs = Gem::Specification.find_all_by_name(name, *requirement) + original_gem_version[name] = version || options[:version] + + gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name]) + say("Gem '#{name}' is not installed") if gem_specs.empty? gem_specs.each do |spec| deplist.add spec @@ -160,16 +163,23 @@ that is a dependency of an existing gem. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/uninstall_command.rb#L163 deps = deplist.strongly_connected_components.flatten.reverse + gems_to_uninstall = {} + deps.each do |dep| - options[:version] = dep.version - uninstall_gem(dep.name) + unless gems_to_uninstall[dep.name] + gems_to_uninstall[dep.name] = true + + unless original_gem_version[dep.name] == Gem::Requirement.default + options[:version] = dep.version + end + + uninstall_gem(dep.name) + end end end def uninstall_gem(gem_name) uninstall(gem_name) - rescue Gem::InstallError - nil rescue Gem::GemNotInHomeException => e spec = e.spec alert("In order to remove #{spec.name}, please execute:\n" + Index: lib/rubygems/commands/cert_command.rb =================================================================== --- lib/rubygems/commands/cert_command.rb (revision 67414) +++ lib/rubygems/commands/cert_command.rb (revision 67415) @@ -319,5 +319,4 @@ For further reading on signing gems see https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cert_command.rb#L319 email =~ /\A.+@.+\z/ end - end if defined?(OpenSSL::SSL) Index: lib/rubygems/basic_specification.rb =================================================================== --- lib/rubygems/basic_specification.rb (revision 67414) +++ lib/rubygems/basic_specification.rb (revision 67415) @@ -71,7 +71,7 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L71 elsif missing_extensions? @ignored = true - if platform == RUBY_ENGINE + if RUBY_ENGINE == platform || Gem::Platform.local === platform warn "Ignoring #{full_name} because its extensions are not built. " + "Try: gem pristine #{name} --version #{version}" end Index: test/rubygems/test_gem_commands_yank_command.rb =================================================================== --- test/rubygems/test_gem_commands_yank_command.rb (revision 67414) +++ test/rubygems/test_gem_commands_yank_command.rb (revision 67415) @@ -49,7 +49,6 @@ class TestGemCommandsYankCommand < Gem:: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_yank_command.rb#L49 assert_match %r%Yanking gem from http://example%, @ui.output assert_match %r%Successfully yanked%, @ui.output - platform = Gem.platforms[1] body = @fetcher.last_request.body.split('&').sort assert_equal %W[gem_name=a platform=#{platform} version=1.0], body Index: test/rubygems/test_require.rb =================================================================== --- test/rubygems/test_require.rb (revision 67414) +++ test/rubygems/test_require.rb (revision 67415) @@ -381,7 +381,6 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_require.rb#L381 assert_equal %w(a-1), loaded_spec_names end - def test_require_bundler b1 = util_spec('bundler', '1', nil, "lib/bundler/setup.rb") b2a = util_spec('bundler', '2.a', nil, "lib/bundler/setup.rb") Index: test/rubygems/test_gem_package_tar_writer.rb =================================================================== --- test/rubygems/test_gem_package_tar_writer.rb (revision 67414) +++ test/rubygems/test_gem_package_tar_writer.rb (revision 67415) @@ -125,7 +125,6 @@ class TestGemPackageTarWriter < Gem::Pac https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_package_tar_writer.rb#L125 assert_headers_equal(tar_file_header('x', '', 0644, 10, Time.now), @io.string[0, 512]) - assert_equal "aaaaaaaaaa#{"\0" * 502}", @io.string[512, 512] digest = signer.digest_algorithm.new Index: test/rubygems/test_gem.rb =================================================================== --- test/rubygems/test_gem.rb (revision 67414) +++ test/rubygems/test_gem.rb (revision 67415) @@ -954,37 +954,23 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L954 end def test_self_ruby_escaping_spaces_in_path - orig_bindir = RbConfig::CONFIG['bindir'] - orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - - RbConfig::CONFIG['bindir'] = "C:/Ruby 1.8/bin" - RbConfig::CONFIG['EXEEXT'] = ".exe" - - ruby_install_name "ruby" do - with_clean_path_to_ruby do - assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby + with_clean_path_to_ruby do + with_bindir_and_exeext("C:/Ruby 1.8/bin", ".exe") do + ruby_install_name "ruby" do + assert_equal "\"C:/Ruby 1.8/bin/ruby.exe\"", Gem.ruby + end end end - ensure - RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_path_without_spaces - orig_bindir = RbConfig::CONFIG['bindir'] - orig_exe_ext = RbConfig::CONFIG['EXEEXT'] - - RbConfig::CONFIG['bindir'] = "C:/Ruby18/bin" - RbConfig::CONFIG['EXEEXT'] = ".exe" - - ruby_install_name "ruby" do - with_clean_path_to_ruby do - assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby + with_clean_path_to_ruby do + with_bindir_and_exeext("C:/Ruby18/bin", ".exe") do + ruby_install_name "ruby" do + assert_equal "C:/Ruby18/bin/ruby.exe", Gem.ruby + end end end - ensure - RbConfig::CONFIG['bindir'] = orig_bindir - RbConfig::CONFIG['EXEEXT'] = orig_exe_ext end def test_self_ruby_api_version @@ -1902,6 +1888,19 @@ You may need to `gem install -g` to inst https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L1888 end end + def with_bindir_and_exeext(bindir, exeext) + orig_bindir = RbConfig::CONFIG['bindir'] + orig_exe_ext = RbConfig::CONFIG['EXEEXT'] + + RbConfig::CONFIG['bindir'] = bindir + RbConfig::CONFIG['EXEEXT'] = exeext + + yield + ensure + RbConfig::CONFIG['bindir'] = orig_bindir + RbConfig::CONFIG['EXEEXT'] = orig_exe_ext + end + def with_clean_path_to_ruby orig_ruby = Gem.ruby @@ -1909,7 +1908,7 @@ You may need to `gem install -g` to inst https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L1908 yield ensure - Gem.instance_variable_set("@ruby", orig_ruby) + Gem.instance_variable_set :@ruby, orig_ruby end def with_plugin(path) Index: test/rubygems/test_gem_request_set_lockfile_parser.rb =================================================================== --- test/rubygems/test_gem_request_set_lockfile_parser.rb (revision 67414) +++ test/rubygems/test_gem_request_set_lockfile_parser.rb (revision 67415) @@ -67,7 +67,6 @@ class TestGemRequestSetLockfileParser < https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_lockfile_parser.rb#L67 assert_equal File.expand_path("#{@gem_deps_file}.lock"), e.path end - def test_parse write_lockfile <<-LOCKFILE.strip GEM Index: test/rubygems/test_gem_commands_push_command.rb =================================================================== --- test/rubygems/test_gem_commands_push_command.rb (revision 67414) +++ test/rubygems/test_gem_commands_push_command.rb (revision 67415) @@ -250,7 +250,6 @@ class TestGemCommandsPushCommand < Gem:: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_push_command.rb#L250 spec.metadata['allowed_push_host'] = "https://privategemserver.example" end - response = %{ERROR: "#{@host}" is not allowed by the gemspec, which only allows "https://privategemserver.example"} assert_raises Gem::MockGemUi::TermError do Index: test/rubygems/test_gem_commands_owner_command.rb =================================================================== --- test/rubygems/test_gem_commands_owner_command.rb (revision 67414) +++ test/rubygems/test_gem_commands_owner_command.rb (revision 67415) @@ -68,7 +68,6 @@ EOF https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_owner_command.rb#L68 end end - def test_show_owners_setting_up_host_through_env_var response = "- email: user1@e...\n" host = "http://rubygems.example" Index: test/rubygems/test_gem_stub_specification.rb =================================================================== --- test/rubygems/test_gem_stub_specification.rb (revision 67414) +++ test/rubygems/test_gem_stub_specification.rb (revision 67415) @@ -122,7 +122,6 @@ class TestStubSpecification < Gem::TestC https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_stub_specification.rb#L122 end end - def test_missing_extensions_eh stub = stub_with_extension do |s| extconf_rb = File.join s.gem_dir, s.extensions.first Index: test/rubygems/test_gem_dependency.rb =================================================================== --- test/rubygems/test_gem_dependency.rb (revision 67414) +++ test/rubygems/test_gem_dependency.rb (revision 67415) @@ -385,5 +385,4 @@ class TestGemDependency < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_dependency.rb#L385 assert_match "Could not find 'b' (= 2.0) among 1 total gem(s)", e.message end - end Index: test/rubygems/test_gem_commands_setup_command.rb =================================================================== --- test/rubygems/test_gem_commands_setup_command.rb (revision 67414) +++ test/rubygems/test_gem_commands_setup_command.rb (revision 67415) @@ -57,6 +57,7 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L57 FileUtils.mkdir_p 'default/gems' gemspec = Gem::Specification.new + gemspec.author = "Us" gemspec.name = "bundler" gemspec.version = BUNDLER_VERS gemspec.bindir = "exe" @@ -185,16 +186,19 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L186 def test_install_default_bundler_gem @cmd.extend FileUtils - @cmd.install_default_bundler_gem + bin_dir = File.join(@gemhome, 'bin') + @cmd.install_default_bundler_gem bin_dir - if Gem.win_platform? - bundler_spec = Gem::Specification.load("bundler/bundler.gemspec") - default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec") - spec = Gem::Specification.load(default_spec_path) - - spec.executables.each do |e| - assert_path_exists File.join(spec.bin_dir, "#{e}.bat") + bundler_spec = Gem::Specification.load("bundler/bundler.gemspec") + default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec") + spec = Gem::Specification.load(default_spec_path) + + spec.executables.each (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/