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

ruby-changes:40291

From: hsbt <ko1@a...>
Date: Fri, 30 Oct 2015 09:54:38 +0900 (JST)
Subject: [ruby-changes:40291] hsbt:r52372 (trunk): * lib/rubygems: Update to RubyGems HEAD(60d7972).

hsbt	2015-10-30 09:54:12 +0900 (Fri, 30 Oct 2015)

  New Revision: 52372

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

  Log:
    * lib/rubygems: Update to RubyGems HEAD(60d7972).
      this version contains pull requests number of #1343, #1356, #1357, #1363
      at https://github.com/rubygems/rubygems/pulls
    * test/rubygems: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/basic_specification.rb
    trunk/lib/rubygems/commands/environment_command.rb
    trunk/lib/rubygems/commands/help_command.rb
    trunk/lib/rubygems/dependency.rb
    trunk/lib/rubygems/platform.rb
    trunk/lib/rubygems/remote_fetcher.rb
    trunk/lib/rubygems/stub_specification.rb
    trunk/lib/rubygems.rb
    trunk/test/rubygems/test_gem_ext_builder.rb
    trunk/test/rubygems/test_gem_platform.rb
    trunk/test/rubygems/test_gem_remote_fetcher.rb
    trunk/test/rubygems/test_gem_specification.rb
    trunk/test/rubygems/test_require.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52371)
+++ ChangeLog	(revision 52372)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Oct 30 09:54:05 2015  SHIBATA Hiroshi  <hsbt@r...>
+
+	* lib/rubygems: Update to RubyGems HEAD(60d7972).
+	  this version contains pull requests number of #1343, #1356, #1357, #1363
+	  at https://github.com/rubygems/rubygems/pulls
+	* test/rubygems: ditto.
+
 Fri Oct 30 07:38:29 2015  Koichi Sasada  <ko1@a...>
 
 	* insns.def (getinlinecache/setinlinecache): compare ic->ic_cref and
Index: lib/rubygems/basic_specification.rb
===================================================================
--- lib/rubygems/basic_specification.rb	(revision 52371)
+++ lib/rubygems/basic_specification.rb	(revision 52372)
@@ -282,7 +282,7 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L282
              self.require_paths.first
            end
 
-    "#{self.full_gem_path}/#{dirs}"
+    "#{self.full_gem_path}/#{dirs}".untaint
   end
 
   ##
Index: lib/rubygems/commands/environment_command.rb
===================================================================
--- lib/rubygems/commands/environment_command.rb	(revision 52371)
+++ lib/rubygems/commands/environment_command.rb	(revision 52372)
@@ -113,6 +113,8 @@ lib/rubygems/defaults/operating_system.r https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/environment_command.rb#L113
 
     out << "  - INSTALLATION DIRECTORY: #{Gem.dir}\n"
 
+    out << "  - USER INSTALLATION DIRECTORY: #{Gem.user_dir}\n"
+
     out << "  - RUBYGEMS PREFIX: #{Gem.prefix}\n" unless Gem.prefix.nil?
 
     out << "  - RUBY EXECUTABLE: #{Gem.ruby}\n"
Index: lib/rubygems/commands/help_command.rb
===================================================================
--- lib/rubygems/commands/help_command.rb	(revision 52371)
+++ lib/rubygems/commands/help_command.rb	(revision 52372)
@@ -370,15 +370,5 @@ platform. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/help_command.rb#L370
     end
   end
 
-  def show_help # :nodoc:
-    command = @command_manager[options[:help]]
-    if command then
-      # help with provided command
-      command.invoke("--help")
-    else
-      alert_error "Unknown command #{options[:help]}.  Try 'gem help commands'"
-    end
-  end
-
 end
 
Index: lib/rubygems/stub_specification.rb
===================================================================
--- lib/rubygems/stub_specification.rb	(revision 52371)
+++ lib/rubygems/stub_specification.rb	(revision 52372)
@@ -19,7 +19,7 @@ class Gem::StubSpecification < Gem::Basi https://github.com/ruby/ruby/blob/trunk/lib/rubygems/stub_specification.rb#L19
 
     def initialize(data)
       parts          = data[PREFIX.length..-1].split(" ")
-      @name          = parts[0]
+      @name          = parts[0].freeze
       @version       = Gem::Version.new parts[1]
       @platform      = Gem::Platform.new parts[2]
       @require_paths = parts.drop(3).join(" ").split("\0")
@@ -35,6 +35,8 @@ class Gem::StubSpecification < Gem::Basi https://github.com/ruby/ruby/blob/trunk/lib/rubygems/stub_specification.rb#L35
   end
 
   def initialize filename, default_gem
+    filename.untaint
+
     self.loaded_from = filename
     @data            = nil
     @extensions      = nil
Index: lib/rubygems/dependency.rb
===================================================================
--- lib/rubygems/dependency.rb	(revision 52371)
+++ lib/rubygems/dependency.rb	(revision 52372)
@@ -280,7 +280,7 @@ class Gem::Dependency https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency.rb#L280
 
     if platform_only
       matches.reject! { |spec|
-        not Gem::Platform.match spec.platform
+        spec.nil? || !Gem::Platform.match(spec.platform)
       }
     end
 
@@ -326,11 +326,11 @@ class Gem::Dependency https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency.rb#L326
   def to_spec
     matches = self.to_specs
 
-    active = matches.find { |spec| spec.activated? }
+    active = matches.find { |spec| spec && spec.activated? }
 
     return active if active
 
-    matches.delete_if { |spec| spec.version.prerelease? } unless prerelease?
+    matches.delete_if { |spec| spec.nil? || spec.version.prerelease? } unless prerelease?
 
     matches.last
   end
Index: lib/rubygems/platform.rb
===================================================================
--- lib/rubygems/platform.rb	(revision 52371)
+++ lib/rubygems/platform.rb	(revision 52372)
@@ -148,8 +148,8 @@ class Gem::Platform https://github.com/ruby/ruby/blob/trunk/lib/rubygems/platform.rb#L148
     return nil unless Gem::Platform === other
 
     # cpu
-    (@cpu == 'universal' or other.cpu == 'universal' or @cpu == other.cpu or
-     (@cpu == 'arm' and other.cpu =~ /\Aarm/)) and
+    ([nil,'universal'].include?(@cpu) or [nil, 'universal'].include?(other.cpu) or @cpu == other.cpu or
+    (@cpu == 'arm' and other.cpu =~ /\Aarm/)) and
 
     # os
     @os == other.os and
Index: lib/rubygems/remote_fetcher.rb
===================================================================
--- lib/rubygems/remote_fetcher.rb	(revision 52371)
+++ lib/rubygems/remote_fetcher.rb	(revision 52372)
@@ -51,6 +51,8 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L51
     @fetcher ||= self.new Gem.configuration[:http_proxy]
   end
 
+  attr_accessor :headers
+
   ##
   # Initialize a remote fetcher using the source URI and possible proxy
   # information.
@@ -64,8 +66,11 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L66
   #
   # +dns+: An object to use for DNS resolution of the API endpoint.
   #        By default, use Resolv::DNS.
+  #
+  # +headers+: A set of additional HTTP headers to be sent to the server when
+  #            fetching the gem.
 
-  def initialize(proxy=nil, dns=Resolv::DNS.new)
+  def initialize(proxy=nil, dns=Resolv::DNS.new, headers={})
     require 'net/http'
     require 'stringio'
     require 'time'
@@ -79,6 +84,7 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L84
     @cert_files = Gem::Request.get_cert_files
 
     @dns = dns
+    @headers = headers
   end
 
   ##
@@ -235,7 +241,9 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L241
 
   def fetch_http uri, last_modified = nil, head = false, depth = 0
     fetch_type = head ? Net::HTTP::Head : Net::HTTP::Get
-    response   = request uri, fetch_type, last_modified
+    response   = request uri, fetch_type, last_modified do |req|
+      headers.each { |k,v| req.add_field(k,v) }
+    end
 
     case response
     when Net::HTTPOK, Net::HTTPNotModified then
@@ -313,9 +321,19 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L321
     end
 
     if update and path
-      open(path, 'wb') do |io|
-        io.flock(File::LOCK_EX)
-        io.write data
+      begin
+        open(path, 'wb') do |io|
+          io.flock(File::LOCK_EX)
+          io.write data
+        end
+      rescue Errno::ENOLCK # NFS
+        if Thread.main != Thread.current
+          raise
+        else
+          open(path, 'wb') do |io|
+            io.write data
+          end
+        end
       end
     end
 
Index: lib/rubygems.rb
===================================================================
--- lib/rubygems.rb	(revision 52371)
+++ lib/rubygems.rb	(revision 52372)
@@ -597,6 +597,9 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L597
 
     test_syck = ENV['TEST_SYCK']
 
+    # Only Ruby 1.8 and 1.9 have syck
+    test_syck = false unless /^1\./ =~ RUBY_VERSION
+
     unless test_syck
       begin
         gem 'psych', '>= 1.2.1'
@@ -778,6 +781,14 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L781
     open path, 'rb' do |f|
       f.read
     end
+  rescue Errno::ENOLCK # NFS
+    if Thread.main != Thread.current
+      raise
+    else
+      open path, 'rb' do |f|
+        f.read
+      end
+    end
   end
 
   ##
Index: test/rubygems/test_require.rb
===================================================================
--- test/rubygems/test_require.rb	(revision 52371)
+++ test/rubygems/test_require.rb	(revision 52372)
@@ -80,6 +80,8 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_require.rb#L80
   end
 
   def test_concurrent_require
+    skip 'deadlock' if /^1\.8\./ =~ RUBY_VERSION
+
     Object.const_set :FILE_ENTERED_LATCH, Latch.new(2)
     Object.const_set :FILE_EXIT_LATCH, Latch.new(1)
 
@@ -103,6 +105,8 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_require.rb#L105
     assert t1.join, "thread 1 should exit"
     assert t2.join, "thread 2 should exit"
   ensure
+    return if $! # skipping
+
     Object.send :remove_const, :FILE_ENTERED_LATCH
     Object.send :remove_const, :FILE_EXIT_LATCH
   end
@@ -247,6 +251,32 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_require.rb#L251
     assert_equal "unable to find a version of 'b' to activate", e.message
   end
 
+  def test_require_works_after_cleanup
+    a1 = new_default_spec "a", "1.0", nil, "a/b.rb"
+    b1 = new_default_spec "b", "1.0", nil, "b/c.rb"
+    b2 = new_default_spec "b", "2.0", nil, "b/d.rb"
+
+    install_default_gems a1
+    install_default_gems b1
+    install_default_gems b2
+
+    # Load default ruby gems fresh as if we've just started a ruby script.
+    Gem::Specification.reset
+    require 'rubygems'
+    Gem::Specification.stubs
+
+    # Remove an old default gem version directly from disk as if someone ran
+    # gem cleanup.
+    FileUtils.rm_rf(File.join @default_dir, "#{b1.full_name}")
+    FileUtils.rm_rf(File.join @default_spec_dir, "#{b1.full_name}.gemspec")
+
+    # Require gems that have not been removed.
+    assert_require 'a/b'
+    assert_equal %w(a-1.0), loaded_spec_names
+    assert_require 'b/d'
+    assert_equal %w(a-1.0 b-2.0), loaded_spec_names
+  end
+
   def test_default_gem_only
     default_gem_spec = new_default_spec("default", "2.0.0.0",
                                         nil, "default/gem.rb")
Index: test/rubygems/test_gem_remote_fetcher.rb
===================================================================
--- test/rubygems/test_gem_remote_fetcher.rb	(revision 52371)
+++ test/rubygems/test_gem_remote_fetcher.rb	(revision 52372)
@@ -698,6 +698,14 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L698
     assert_equal "too many redirects (#{url})", e.message
   end
 
+  def test_fetch_http_with_additional_headers
+    ENV["http_proxy"] = @proxy_uri
+    ENV["no_proxy"] = URI::parse(@server_uri).host
+    fetcher = Gem::RemoteFetcher.new nil, nil, {"X-Captain" => "murphy"}
+    @fetcher = fetcher
+    assert_equal "murphy", fetcher.fetch_path(@server_uri)
+  end
+
   def test_fetch_s3
     fetcher = Gem::RemoteFetcher.new nil
     @fetcher = fetcher
@@ -984,7 +992,9 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L992
         )
       s.mount_proc("/kill") { |req, res| s.shutdown }
       s.mount_proc("/yaml") { |req, res|
-        if @enable_yaml
+        if req["X-Captain"]
+          res.body = req["X-Captain"]
+        elsif @enable_yaml
           res.body = data
           res['Content-Type'] = 'text/plain'
           res['content-length'] = data.size
Index: test/rubygems/test_gem_platform.rb
===================================================================
--- test/rubygems/test_gem_platform.rb	(revision 52371)
+++ test/rubygems/test_gem_platform.rb	(revision 52372)
@@ -190,6 +190,17 @@ class TestGemPlatform < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_platform.rb#L190
     assert((x86_darwin8 === Gem::Platform.local), 'universal =~ x86')
   end
 
+  def test_nil_cpu_arch_is_treated_as_universal
+    with_nil_arch = Gem::Platform.new [nil, 'mingw32']
+    with_uni_arch = Gem::Platform.new ['universal', 'mingw32']
+    with_x86_arch = Gem::Platform.new ['x86', 'mingw32']
+
+    assert((with_nil_arch === with_uni_arch), 'nil =~ universal')
+    assert((with_uni_arch === with_nil_arch), 'universal =~ nil')
+    assert((with_nil_arch === with_x86_arch), 'nil =~ x86')
+    assert((with_x86_arch === with_nil_arch), 'x86 =~ nil')
+  end
+
   def test_equals3_cpu_arm
     arm   = Gem::Platform.new 'arm-linux'
     armv5 = Gem::Platform.new 'armv5-linux'
Index: test/rubygems/test_gem_specification.rb
===================================================================
--- test/rubygems/test_gem_specification.rb	(revision 52371)
+++ test/rubygems/test_gem_specification.rb	(revision 52372)
@@ -1724,6 +1724,8 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L1724
     class << Gem
       alias orig_default_ext_dir_for default_ext_dir_for
 
+      remove_method :default_ext_dir_for
+
       def Gem.default_ext_dir_for(base_dir)
         'elsewhere'
       end
@@ -2033,6 +2035,8 @@ dependencies: [] https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L2035
   def test_require_paths_default_ext_dir_for
     class << Gem
       send :alias_method, :orig_default_ext_dir_for, :default_ext_dir_for
+
+      remove_method :default_ext_dir_for
     end
 
     def Gem.default_ext_dir_for base_dir
Index: test/rubygems/test_gem_ext_builder.rb
===================================================================
--- test/rubygems/test_gem_ext_builder.rb	(revision 52371)
+++ test/rubygems/test_gem_ext_builder.rb	(revision 52372)
@@ -147,6 +147,8 @@ install: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_ext_builder.rb#L147
     class << Gem
       alias orig_install_extension_in_lib install_extension_in_lib
 
+      remove_method :install_extension_in_lib
+
       def Gem.install_extension_in_lib
         false
       end

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

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