[前][次][番号順一覧][スレッド一覧]

ruby-changes:54688

From: hsbt <ko1@a...>
Date: Tue, 22 Jan 2019 15:28:09 +0900 (JST)
Subject: [ruby-changes:54688] hsbt:r66904 (trunk): Merge rubygems master targeted RubyGems 3.1.0.

hsbt	2019-01-22 15:28:04 +0900 (Tue, 22 Jan 2019)

  New Revision: 66904

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66904

  Log:
    Merge rubygems master targeted RubyGems 3.1.0.
    
      https://github.com/rubygems/rubygems/commit/1172320540c8c33c59fc1db5191b021c3b2db487

  Modified files:
    trunk/lib/rubygems/commands/build_command.rb
    trunk/lib/rubygems/commands/push_command.rb
    trunk/lib/rubygems/gemcutter_utilities.rb
    trunk/lib/rubygems/rdoc.rb
    trunk/lib/rubygems/request.rb
    trunk/lib/rubygems/resolver.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/lib/rubygems/validator.rb
    trunk/lib/rubygems.rb
    trunk/test/rubygems/test_gem.rb
    trunk/test/rubygems/test_gem_commands_build_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_ext_cmake_builder.rb
    trunk/test/rubygems/test_gem_request.rb
    trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb
    trunk/test/rubygems/test_gem_specification.rb
Index: lib/rubygems/test_case.rb
===================================================================
--- lib/rubygems/test_case.rb	(revision 66903)
+++ lib/rubygems/test_case.rb	(revision 66904)
@@ -1057,6 +1057,8 @@ Also, a list: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L1057
     Gem.instance_variable_set :@platforms, nil
     Gem::Platform.instance_variable_set :@local, nil
 
+    yield if block_given?
+
     platform
   end
 
Index: lib/rubygems/validator.rb
===================================================================
--- lib/rubygems/validator.rb	(revision 66903)
+++ lib/rubygems/validator.rb	(revision 66904)
@@ -19,29 +19,6 @@ class Gem::Validator https://github.com/ruby/ruby/blob/trunk/lib/rubygems/validator.rb#L19
     require 'find'
   end
 
-  ##
-  # Given a gem file's contents, validates against its own MD5 checksum
-  # gem_data:: [String] Contents of the gem file
-
-  def verify_gem(gem_data)
-    # TODO remove me? The code here only validate an MD5SUM that was
-    # in some old formatted gems, but hasn't been for a long time.
-  end
-
-  ##
-  # Given the path to a gem file, validates against its own MD5 checksum
-  #
-  # gem_path:: [String] Path to gem file
-
-  def verify_gem_file(gem_path)
-    File.open gem_path, Gem.binary_mode do |file|
-      gem_data = file.read
-      verify_gem gem_data
-    end
-  rescue Errno::ENOENT, Errno::EINVAL
-    raise Gem::VerificationError, "missing gem file #{gem_path}"
-  end
-
   private
 
   def find_files_for_gem(gem_directory)
@@ -105,7 +82,9 @@ class Gem::Validator https://github.com/ruby/ruby/blob/trunk/lib/rubygems/validator.rb#L82
       end
 
       begin
-        verify_gem_file(gem_path)
+        unless File.readable?(gem_path)
+          raise Gem::VerificationError, "missing gem file #{gem_path}"
+        end
 
         good, gone, unreadable = nil, nil, nil, nil
 
Index: lib/rubygems/rdoc.rb
===================================================================
--- lib/rubygems/rdoc.rb	(revision 66903)
+++ lib/rubygems/rdoc.rb	(revision 66904)
@@ -18,7 +18,7 @@ begin https://github.com/ruby/ruby/blob/trunk/lib/rubygems/rdoc.rb#L18
   module Gem
     RDoc = ::RDoc::RubygemsHook
   end
+
+  Gem.done_installing(&Gem::RDoc.method(:generation_hook))
 rescue LoadError
 end
-
-Gem.done_installing(&Gem::RDoc.method(:generation_hook))
Index: lib/rubygems/gemcutter_utilities.rb
===================================================================
--- lib/rubygems/gemcutter_utilities.rb	(revision 66903)
+++ lib/rubygems/gemcutter_utilities.rb	(revision 66904)
@@ -38,7 +38,9 @@ module Gem::GemcutterUtilities https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L38
   # The API key from the command options or from the user's configuration.
 
   def api_key
-    if options[:key]
+    if ENV["GEM_HOST_API_KEY"]
+      ENV["GEM_HOST_API_KEY"]
+    elsif options[:key]
       verify_api_key options[:key]
     elsif Gem.configuration.api_keys.key?(host)
       Gem.configuration.api_keys[host]
Index: lib/rubygems/specification.rb
===================================================================
--- lib/rubygems/specification.rb	(revision 66903)
+++ lib/rubygems/specification.rb	(revision 66904)
@@ -1285,7 +1285,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1285
     unresolved = unresolved_deps
     unless unresolved.empty?
       w = "W" + "ARN"
-      warn "#{w}: Unresolved or ambigious specs during Gem::Specification.reset:"
+      warn "#{w}: Unresolved or ambiguous specs during Gem::Specification.reset:"
       unresolved.values.each do |dep|
         warn "      #{dep}"
 
@@ -2254,6 +2254,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L2254
 
       attributes.each do |attr_name|
         current_value = self.send attr_name
+        current_value = current_value.sort if %i(files test_files).include? attr_name
         if current_value != default_value(attr_name) or
            self.class.required_attribute? attr_name
 
Index: lib/rubygems/commands/build_command.rb
===================================================================
--- lib/rubygems/commands/build_command.rb	(revision 66903)
+++ lib/rubygems/commands/build_command.rb	(revision 66904)
@@ -18,6 +18,10 @@ class Gem::Commands::BuildCommand < Gem: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/build_command.rb#L18
     add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
       options[:output] = value
     end
+
+    add_option '-C PATH', '', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options|
+      options[:build_path] = value
+    end
   end
 
   def arguments # :nodoc:
@@ -60,25 +64,36 @@ Gems can be saved to a specified filenam https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/build_command.rb#L64
     end
 
     if File.exist? gemspec
-      Dir.chdir(File.dirname(gemspec)) do
-        spec = Gem::Specification.load File.basename(gemspec)
+      spec = Gem::Specification.load(gemspec)
 
-        if spec
-          Gem::Package.build(
-            spec,
-            options[:force],
-            options[:strict],
-            options[:output]
-          )
-        else
-          alert_error "Error loading gemspec. Aborting."
-          terminate_interaction 1
+      if options[:build_path]
+        Dir.chdir(File.dirname(gemspec)) do
+          spec = Gem::Specification.load File.basename(gemspec)
+          build_package(spec)
         end
+      else
+        build_package(spec)
       end
+
     else
       alert_error "Gemspec file not found: #{gemspec}"
       terminate_interaction 1
     end
   end
 
+  private
+
+  def build_package(spec)
+    if spec
+      Gem::Package.build(
+        spec,
+        options[:force],
+        options[:strict],
+        options[:output]
+      )
+    else
+      alert_error "Error loading gemspec. Aborting."
+      terminate_interaction 1
+    end
+  end
 end
Index: lib/rubygems/commands/push_command.rb
===================================================================
--- lib/rubygems/commands/push_command.rb	(revision 66903)
+++ lib/rubygems/commands/push_command.rb	(revision 66904)
@@ -15,6 +15,8 @@ https://rubygems.org) and adds it to the https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/push_command.rb#L15
 
 The gem can be removed from the index and deleted from the server using the yank
 command.  For further discussion see the help for the yank command.
+
+The push command will use ~/.gem/credentials to authenticate to a server, but you can use the RubyGems environment variable GEM_HOST_API_KEY to set the api key to authenticate.
     EOF
   end
 
Index: lib/rubygems/request.rb
===================================================================
--- lib/rubygems/request.rb	(revision 66903)
+++ lib/rubygems/request.rb	(revision 66904)
@@ -168,6 +168,7 @@ class Gem::Request https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request.rb#L168
 
     no_env_proxy = env_proxy.nil? || env_proxy.empty?
 
+    return :no_proxy if scheme == 'https' && no_env_proxy
     return get_proxy_from_env 'http' if no_env_proxy and _scheme != 'http'
     return :no_proxy                 if no_env_proxy
 
Index: lib/rubygems/resolver.rb
===================================================================
--- lib/rubygems/resolver.rb	(revision 66903)
+++ lib/rubygems/resolver.rb	(revision 66904)
@@ -231,8 +231,6 @@ class Gem::Resolver https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver.rb#L231
       raise exc
     end
 
-    sources = []
-
     groups = Hash.new { |hash, key| hash[key] = [] }
 
     # create groups & sources in the same loop
Index: lib/rubygems.rb
===================================================================
--- lib/rubygems.rb	(revision 66903)
+++ lib/rubygems.rb	(revision 66904)
@@ -9,7 +9,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L9
 require 'rbconfig'
 
 module Gem
-  VERSION = "3.0.2".freeze
+  VERSION = "3.1.0.pre1".freeze
 end
 
 # Must be first since it unloads the prelude from 1.9.2
Index: test/rubygems/test_gem_request.rb
===================================================================
--- test/rubygems/test_gem_request.rb	(revision 66903)
+++ test/rubygems/test_gem_request.rb	(revision 66904)
@@ -79,6 +79,17 @@ class TestGemRequest < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request.rb#L79
     assert_equal URI(@proxy_uri), proxy
   end
 
+  def test_proxy_ENV
+    ENV['http_proxy'] = "http://proxy"
+    ENV['https_proxy'] = ""
+
+    request = make_request URI('https://example'), nil, nil, nil
+
+    proxy = request.proxy_uri
+
+    assert_nil proxy
+  end
+
   def test_configure_connection_for_https
     connection = Net::HTTP.new 'localhost', 443
 
Index: test/rubygems/test_gem_commands_push_command.rb
===================================================================
--- test/rubygems/test_gem_commands_push_command.rb	(revision 66903)
+++ test/rubygems/test_gem_commands_push_command.rb	(revision 66904)
@@ -199,6 +199,21 @@ class TestGemCommandsPushCommand < Gem:: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_push_command.rb#L199
     send_battery
   end
 
+  def test_sending_gem_with_env_var_api_key
+    @host = "http://privategemserver.example"
+
+    @spec, @path = util_gem "freebird", "1.0.1" do |spec|
+      spec.metadata['allowed_push_host'] = @host
+    end
+
+    @api_key = "PRIVKEY"
+    ENV["GEM_HOST_API_KEY"] = "PRIVKEY"
+
+    @response = "Successfully registered gem: freebird (1.0.1)"
+    @fetcher.data["#{@host}/api/v1/gems"]  = [@response, 200, 'OK']
+    send_battery
+  end
+
   def test_sending_gem_to_allowed_push_host_with_basic_credentials
     @sanitized_host = "http://privategemserver.example"
     @host           = "http://user:password@p..."
Index: test/rubygems/test_gem_commands_setup_command.rb
===================================================================
--- test/rubygems/test_gem_commands_setup_command.rb	(revision 66903)
+++ test/rubygems/test_gem_commands_setup_command.rb	(revision 66904)
@@ -10,7 +10,7 @@ class TestGemCommandsSetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L10
   if File.exist?(bundler_gemspec)
     BUNDLER_VERS = File.read(bundler_gemspec).match(/VERSION = "(#{Gem::Version::VERSION_PATTERN})"/)[1]
   else
-    BUNDLER_VERS = "1.16.2".freeze
+    BUNDLER_VERS = "2.0.1".freeze
   end
 
   def setup
Index: test/rubygems/test_gem_commands_build_command.rb
===================================================================
--- test/rubygems/test_gem_commands_build_command.rb	(revision 66903)
+++ test/rubygems/test_gem_commands_build_command.rb	(revision 66904)
@@ -207,6 +207,7 @@ class TestGemCommandsBuildCommand < Gem: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_build_command.rb#L207
       gs.write @gem.to_ruby
     end
 
+    @cmd.options[:build_path] = gemspec_dir
     @cmd.options[:args] = [gemspec_file]
 
     use_ui @ui do
Index: test/rubygems/test_gem_specification.rb
===================================================================
--- test/rubygems/test_gem_specification.rb	(revision 66903)
+++ test/rubygems/test_gem_specification.rb	(revision 66904)
@@ -2936,7 +2936,7 @@ duplicate dependency on c (>= 1.2.3, dev https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2936
     end
 
     expected = <<-EXPECTED
-WARN: Unresolved or ambigious specs during Gem::Specification.reset:
+WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
       x (= 1)
 WARN: Clearing out unresolved specs. Try 'gem cleanup <gem>'
 Please report a bug if this causes problems.
@@ -2964,7 +2964,7 @@ Please report a bug if this causes probl https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2964
     end
 
     expected = <<-EXPECTED
-WARN: Unresolved or ambigious specs during Gem::Specification.reset:
+WARN: Unresolved or ambiguous specs during Gem::Specification.reset:
       x (= 1)
       Available/installed versions of this gem:
       - 1
Index: test/rubygems/test_gem_request_set_gem_dependency_api.rb
===================================================================
--- test/rubygems/test_gem_request_set_gem_dependency_api.rb	(revision 66903)
+++ test/rubygems/test_gem_request_set_gem_dependency_api.rb	(revision 66904)
@@ -652,20 +652,23 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb#L652
   end
 
   def test_platform_mswin
-    util_set_arch 'i686-darwin8.10.1' do
-      @gda.platform :mswin do
-        @gda.gem 'a'
-      end
-
-      assert_empty @set.dependencies
-    end
+    if win_platform?
+      util_set_arch 'x86-mswin32-60' do
+        @gda.platform :mswin do
+          @gda.gem 'a'
+        end
+
+        assert_equal [dep('a')], @set.dependencies
+        refute_empty @set.dependencies
+      end
+    else
+      util_set_arch 'i686-darwin8.10.1' do
+        @gda.platform :mswin do
+          @gda.gem 'a'
+        end
 
-    util_set_arch 'x86-mswin32-60' do
-      @gda.platform :mswin do
-        @gda.gem 'a'
+        assert_empty @set.dependencies
       end
-
-      refute_empty @set.dependencies
     end
   end
 
@@ -708,26 +711,20 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb#L711
   end
 
   def test_platforms
-    util_set_arch 'i686-darwin8.10.1' do
-      @gda.platforms :ruby do
-        @gda.gem 'a'
-      end
-
-      assert_equal [dep('a')], @set.dependencies
+    unless win_platform?
+      util_set_arch 'i686-darwin8.10.1' do
+        @gda.platforms :ruby do
+          @gda.gem 'a'
+        end
+
+        assert_equal [dep('a')], @set.dependencies
+
+        @gda.platforms :mswin do
+          @gda.gem 'b'
+        end
 
-      @gda.platforms :mswin do
-        @gda.gem 'b'
+        assert_equal [dep('a')], @set.dependencies
       end
-
-      assert_equal [dep('a')], @set.dependencies
-    end
-
-    util_set_arch 'x86-mswin32-60' do
-      @gda.platforms :mswin do
-        @gda.gem 'c'
-      end
-
-      assert_equal [dep('a'), dep('c')], @set.dependencies
     end
   end
 
Index: test/rubygems/test_gem_ext_cmake_builder.rb
===================================================================
--- test/rubygems/test_gem_ext_cmake_builder.rb	(revision 66903)
+++ test/rubygems/test_gem_ext_cmake_builder.rb	(revision 66904)
@@ -25,7 +25,7 @@ class TestGemExtCmakeBuilder < Gem::Test https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_ext_cmake_builder.rb#L25
     File.open File.join(@ext, 'CMakeLists.txt'), 'w' do |cmakelists|
       cmakelists.write <<-eo_cmake
 cmake_minimum_required(VERSION 2.6)
-project(self_build LANGUAGES NONE)
+project(self_build NONE)
 install (FILES test.txt DESTINATION bin)
       eo_cmake
     end
Index: test/rubygems/test_gem.rb
===================================================================
--- test/rubygems/test_gem.rb	(revision 66903)
+++ test/rubygems/test_gem.rb	(revision 66904)
@@ -156,7 +156,7 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L156
   end
 
   def assert_self_install_permissions
-    mask = /mingw|mswin/ =~ RUBY_PLATFORM ? 0700 : 0777
+    mask = win_platform? ? 0700 : 0777
     options = {
       :dir_mode => 0500,
       :prog_mode => 0510,
@@ -198,6 +198,9 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L198
       'gems/foo-1/bin/foo.cmd' => prog_mode,
       'gems/foo-1/data/foo.txt' => data_mode,
     }
+    # below is for intermittent errors on Appveyor & Travis 2019-01,
+    # see https://github.com/rubygems/rubygems/pull/2568
+    sleep 0.2
     result = {}
     Dir.chdir @gemhome do
       expected.each_key do |n|

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]