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

ruby-changes:27745

From: nagachika <ko1@a...>
Date: Mon, 18 Mar 2013 00:01:59 +0900 (JST)
Subject: [ruby-changes:27745] nagachika:r39797 (ruby_2_0_0): merge revision(s) 39606,39609: [Backport #8019]

nagachika	2013-03-18 00:01:47 +0900 (Mon, 18 Mar 2013)

  New Revision: 39797

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

  Log:
    merge revision(s) 39606,39609: [Backport #8019]
    
    * lib/rubygems/commands/query_command.rb:  Only fetch remote specs when
      showing details.  [ruby-trunk - Bug #8019]  RubyGems bug #487
    
    * lib/rubygems/remote_fetcher.rb:  ditto.
    
    * lib/rubygems/security/policy.rb:  ditto.
    
    * test/rubygems/test_gem_commands_query_command.rb:  Test for the
      above.
    
    * lib/rubygems/security.rb:  Make OpenSSL optional for RubyGems.
    
    * lib/rubygems/commands/cert_command.rb:  ditto.
    
    * lib/rubygems/config_file.rb:  Display file with YAML error, not
      ~/.gemrc
    
    * lib/rubygems/remote_fetcher.rb:  Only create gem subdirectories when
      installing gems.
    
    * lib/rubygems/dependency_resolver.rb:  ditto.
    
    * lib/rubygems/test_utilities.rb:  ditto.
    
    * test/rubygems/test_gem_commands_fetch_command.rb:  Test for the
      above.
    
    * lib/rubygems/spec_fetcher.rb:  Only try to upgrade
      http://rubygems.org to HTTPS
    
    * test/rubygems/test_gem_spec_fetcher.rb:  Test for the above.
    
    * lib/rubygems.rb:  Update win_platform? check for JRuby compatibility.
    
    * test/rubygems/test_gem_installer.rb:  Update for Ruby 1.9.2
      compatibility
    
    * test/rubygems/test_gem_spec_fetcher.rb:  Removed unused variable.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/lib/rubygems/commands/cert_command.rb
    branches/ruby_2_0_0/lib/rubygems/commands/query_command.rb
    branches/ruby_2_0_0/lib/rubygems/config_file.rb
    branches/ruby_2_0_0/lib/rubygems/dependency_resolver.rb
    branches/ruby_2_0_0/lib/rubygems/remote_fetcher.rb
    branches/ruby_2_0_0/lib/rubygems/security/policy.rb
    branches/ruby_2_0_0/lib/rubygems/security.rb
    branches/ruby_2_0_0/lib/rubygems/spec_fetcher.rb
    branches/ruby_2_0_0/lib/rubygems/test_utilities.rb
    branches/ruby_2_0_0/lib/rubygems.rb
    branches/ruby_2_0_0/test/rubygems/test_gem_commands_fetch_command.rb
    branches/ruby_2_0_0/test/rubygems/test_gem_commands_query_command.rb
    branches/ruby_2_0_0/test/rubygems/test_gem_installer.rb
    branches/ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 39796)
+++ ruby_2_0_0/ChangeLog	(revision 39797)
@@ -1,3 +1,38 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Mar 18 00:00:32 2013  Eric Hodel  <drbrain@s...>
+
+	* test/rubygems/test_gem_spec_fetcher.rb:  Removed unused variable.
+
+Mon Mar 18 00:00:32 2013  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems/commands/query_command.rb:  Only fetch remote specs when
+	  showing details.  [ruby-trunk - Bug #8019]  RubyGems bug #487
+	* lib/rubygems/remote_fetcher.rb:  ditto.
+	* lib/rubygems/security/policy.rb:  ditto.
+	* test/rubygems/test_gem_commands_query_command.rb:  Test for the
+	  above.
+
+	* lib/rubygems/security.rb:  Make OpenSSL optional for RubyGems.
+	* lib/rubygems/commands/cert_command.rb:  ditto.
+
+	* lib/rubygems/config_file.rb:  Display file with YAML error, not
+	  ~/.gemrc
+
+	* lib/rubygems/remote_fetcher.rb:  Only create gem subdirectories when
+	  installing gems.
+	* lib/rubygems/dependency_resolver.rb:  ditto.
+	* lib/rubygems/test_utilities.rb:  ditto.
+	* test/rubygems/test_gem_commands_fetch_command.rb:  Test for the
+	  above.
+
+	* lib/rubygems/spec_fetcher.rb:  Only try to upgrade
+	  http://rubygems.org to HTTPS
+	* test/rubygems/test_gem_spec_fetcher.rb:  Test for the above.
+
+	* lib/rubygems.rb:  Update win_platform? check for JRuby compatibility.
+
+	* test/rubygems/test_gem_installer.rb:  Update for Ruby 1.9.2
+	  compatibility
+
 Sun Mar 17 23:53:19 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/rubygems.rb:  Bump version to 2.0.1 for upcoming bugfix release
Index: ruby_2_0_0/lib/rubygems/spec_fetcher.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/spec_fetcher.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/spec_fetcher.rb	(revision 39797)
@@ -228,10 +228,14 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/spec_fetcher.rb#L228
     end
   end
 
+  ##
+  # Attempts to upgrade +source+ to HTTPS if it is for http://rubygems.org
+
   def upgrade_http_source source
     uri = source.uri
 
-    return source unless uri.scheme.downcase == 'http'
+    return source unless uri.scheme.downcase == 'http' &&
+                         uri.host.downcase == 'rubygems.org'
 
     https_uri = uri.dup
     https_uri.scheme = 'https'
Index: ruby_2_0_0/lib/rubygems/dependency_resolver.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/dependency_resolver.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/dependency_resolver.rb	(revision 39797)
@@ -406,6 +406,8 @@ module Gem https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/dependency_resolver.rb#L406
           source = Gem.sources.first
         end
 
+        Gem.ensure_gem_subdirectories path
+
         source.download full_spec, path
       end
 
Index: ruby_2_0_0/lib/rubygems/config_file.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/config_file.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/config_file.rb	(revision 39797)
@@ -304,14 +304,14 @@ if you believe they were disclosed to a https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/config_file.rb#L304
     begin
       content = YAML.load(File.read(filename))
       unless content.kind_of? Hash
-        warn "Failed to load #{config_file_name} because it doesn't contain valid YAML hash"
+        warn "Failed to load #{filename} because it doesn't contain valid YAML hash"
         return {}
       end
       return content
     rescue ArgumentError
-      warn "Failed to load #{config_file_name}"
+      warn "Failed to load #{filename}"
     rescue Errno::EACCES
-      warn "Failed to load #{config_file_name} due to permissions problem."
+      warn "Failed to load #{filename} due to permissions problem."
     end
 
     {}
Index: ruby_2_0_0/lib/rubygems/remote_fetcher.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/remote_fetcher.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/remote_fetcher.rb	(revision 39797)
@@ -127,8 +127,6 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/remote_fetcher.rb#L127
   # always replaced.
 
   def download(spec, source_uri, install_dir = Gem.dir)
-    Gem.ensure_gem_subdirectories(install_dir) rescue nil
-
     cache_dir =
       if Dir.pwd == install_dir then # see fetch_command
         install_dir
@@ -403,7 +401,8 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/remote_fetcher.rb#L401
     connection.start unless connection.started?
 
     connection
-  rescue OpenSSL::SSL::SSLError, Errno::EHOSTDOWN => e
+  rescue defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : Errno::EHOSTDOWN,
+         Errno::EHOSTDOWN => e
     raise FetchError.new(e.message, uri)
   end
 
@@ -424,6 +423,12 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/remote_fetcher.rb#L423
       add_rubygems_trusted_certs(store)
     end
     connection.cert_store = store
+  rescue LoadError => e
+    raise unless (e.respond_to?(:path) && e.path == 'openssl') ||
+                 e.message =~ / -- openssl$/
+
+    raise Gem::Exception.new(
+            'Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources')
   end
 
   def add_rubygems_trusted_certs(store)
Index: ruby_2_0_0/lib/rubygems/commands/cert_command.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/commands/cert_command.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/commands/cert_command.rb	(revision 39797)
@@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/commands/cert_command.rb#L1
 require 'rubygems/command'
 require 'rubygems/security'
+require 'openssl'
 
 class Gem::Commands::CertCommand < Gem::Command
 
Index: ruby_2_0_0/lib/rubygems/commands/query_command.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/commands/query_command.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/commands/query_command.rb	(revision 39797)
@@ -192,9 +192,13 @@ class Gem::Commands::QueryCommand < Gem: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/commands/query_command.rb#L192
     end
   end
 
-  def entry_details entry, spec, specs, platforms
+  def entry_details entry, detail_tuple, specs, platforms
     return unless options[:details]
 
+    name_tuple, spec = detail_tuple
+
+    spec = spec.fetch_spec name_tuple unless Gem::Specification === spec
+
     entry << "\n"
 
     spec_platforms   entry, platforms
@@ -228,19 +232,15 @@ class Gem::Commands::QueryCommand < Gem: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/commands/query_command.rb#L232
 
   def make_entry entry_tuples, platforms
     detail_tuple = entry_tuples.first
-    name_tuple, latest_spec = detail_tuple
-
-    latest_spec = latest_spec.fetch_spec name_tuple unless
-      Gem::Specification === latest_spec
 
     name_tuples, specs = entry_tuples.flatten.partition do |item|
       Gem::NameTuple === item
     end
 
-    entry = [latest_spec.name]
+    entry = [name_tuples.first.name]
 
     entry_versions entry, name_tuples, platforms
-    entry_details  entry, latest_spec, specs, platforms
+    entry_details  entry, detail_tuple, specs, platforms
 
     entry.join
   end
Index: ruby_2_0_0/lib/rubygems/security/policy.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/security/policy.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/security/policy.rb	(revision 39797)
@@ -20,6 +20,8 @@ class Gem::Security::Policy https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/security/policy.rb#L20
   # options.
 
   def initialize name, policy = {}, opt = {}
+    require 'openssl'
+
     @name = name
 
     @opt = opt
Index: ruby_2_0_0/lib/rubygems/security.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/security.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/security.rb	(revision 39797)
@@ -5,9 +5,29 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/security.rb#L5
 #++
 
 require 'rubygems/exceptions'
-require 'openssl'
 require 'fileutils'
 
+begin
+  require 'openssl'
+rescue LoadError => e
+  raise unless (e.respond_to?(:path) && e.path == 'openssl') ||
+               e.message =~ / -- openssl$/
+
+  module OpenSSL # :nodoc:
+    class Digest # :nodoc:
+      class SHA1 # :nodoc:
+        def name
+          'SHA1'
+        end
+      end
+    end
+    module PKey # :nodoc:
+      class RSA # :nodoc:
+      end
+    end
+  end
+end
+
 ##
 # = Signing gems
 #
Index: ruby_2_0_0/lib/rubygems/test_utilities.rb
===================================================================
--- ruby_2_0_0/lib/rubygems/test_utilities.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems/test_utilities.rb	(revision 39797)
@@ -121,8 +121,6 @@ class Gem::FakeFetcher https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems/test_utilities.rb#L121
 
     path = File.join path, name
 
-    Gem.ensure_gem_subdirectories install_dir
-
     if source_uri =~ /^http/ then
       File.open(path, "wb") do |f|
         f.write fetch_path(File.join(source_uri, "gems", name))
Index: ruby_2_0_0/lib/rubygems.rb
===================================================================
--- ruby_2_0_0/lib/rubygems.rb	(revision 39796)
+++ ruby_2_0_0/lib/rubygems.rb	(revision 39797)
@@ -895,7 +895,8 @@ module Gem https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/lib/rubygems.rb#L895
 
   def self.win_platform?
     if @@win_platform.nil? then
-      @@win_platform = !!WIN_PATTERNS.find { |r| RUBY_PLATFORM =~ r }
+      ruby_platform = RbConfig::CONFIG['host_os']
+      @@win_platform = !!WIN_PATTERNS.find { |r| ruby_platform =~ r }
     end
 
     @@win_platform
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 39796)
+++ ruby_2_0_0/version.h	(revision 39797)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2013-03-17"
-#define RUBY_PATCHLEVEL 66
+#define RUBY_RELEASE_DATE "2013-03-18"
+#define RUBY_PATCHLEVEL 67
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 17
+#define RUBY_RELEASE_DAY 18
 
 #include "ruby/version.h"
 
Index: ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb
===================================================================
--- ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb	(revision 39796)
+++ ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb	(revision 39797)
@@ -245,7 +245,6 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb#L245
 
     source       = Gem::Source.new URI 'http://example'
     same_source  = nil
-    https_source = nil
 
     use_ui @ui do
       same_source = @sf.upgrade_http_source source
@@ -253,19 +252,36 @@ class TestGemSpecFetcher < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_spec_fetcher.rb#L252
 
     assert_equal URI('http://example'), same_source.uri
 
-    @fetcher.data['https://example/'] = 'hello'
+    assert_empty @ui.output
+    assert_empty @ui.error
+  end
+
+  def test_upgrade_http_source_rubygems
+    Gem.configuration.verbose = :really
+
+    source       = Gem::Source.new URI 'http://rubygems.org'
+    same_source  = nil
+    https_source = nil
+
+    use_ui @ui do
+      same_source = @sf.upgrade_http_source source
+    end
+
+    assert_equal URI('http://rubygems.org'), same_source.uri
+
+    @fetcher.data['https://rubygems.org/'] = 'hello'
 
     use_ui @ui do
       https_source = @sf.upgrade_http_source source
     end
 
-    assert_equal URI('https://example'), https_source.uri
+    assert_equal URI('https://rubygems.org'), https_source.uri
 
     assert_empty @ui.error
 
     expected = <<-EXPECTED
-Upgrading http://example to HTTPS failed, continuing
-Upgraded http://example to HTTPS
+Upgrading http://rubygems.org to HTTPS failed, continuing
+Upgraded http://rubygems.org to HTTPS
     EXPECTED
 
     assert_equal expected, @ui.output
Index: ruby_2_0_0/test/rubygems/test_gem_commands_query_command.rb
===================================================================
--- ruby_2_0_0/test/rubygems/test_gem_commands_query_command.rb	(revision 39796)
+++ ruby_2_0_0/test/rubygems/test_gem_commands_query_command.rb	(revision 39797)
@@ -430,5 +430,21 @@ pl \(1\) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_commands_query_command.rb#L430
     assert_equal expected, @ui.output
   end
 
+  def test_make_entry
+    @fetcher.data.delete \
+      "#{@gem_repo}quick/Marshal.#{Gem.marshal_version}/#{@a2.original_name}.gemspec.rz"
+
+    entry_tuples = [
+      [Gem::NameTuple.new(@a2.name, @a2.version, @a2.platform),
+       Gem.sources.first],
+    ]
+
+    platforms = { @a2.version => [@a2.platform] }
+
+    entry = @cmd.send :make_entry, entry_tuples, platforms
+
+    assert_equal 'a (2)', entry
+  end
+
 end
 
Index: ruby_2_0_0/test/rubygems/test_gem_installer.rb
===================================================================
--- ruby_2_0_0/test/rubygems/test_gem_installer.rb	(revision 39796)
+++ ruby_2_0_0/test/rubygems/test_gem_installer.rb	(revision 39797)
@@ -1060,7 +1060,9 @@ gem 'other', version https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_installer.rb#L1060
   end
 
   def test_install_extension_flat
-    skip '1.8 mkmf.rb does not create TOUCH' if RUBY_VERSION < '1.9'
+    skip '1.9.2 and earlier mkmf.rb does not create TOUCH' if
+      RUBY_VERSION < '1.9.3'
+
     @spec.require_paths = ["."]
 
     @spec.extensions << "extconf.rb"
Index: ruby_2_0_0/test/rubygems/test_gem_commands_fetch_command.rb
===================================================================
--- ruby_2_0_0/test/rubygems/test_gem_commands_fetch_command.rb	(revision 39796)
+++ ruby_2_0_0/test/rubygems/test_gem_commands_fetch_command.rb	(revision 39797)
@@ -18,6 +18,8 @@ class TestGemCommandsFetchCommand < Gem: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_commands_fetch_command.rb#L18
     @fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
       File.read(@a2.cache_file)
 
+    refute_path_exists File.join(@tempdir, 'cache'), 'sanity check'
+
     @cmd.options[:args] = [@a2.name]
 
     use_ui @ui do
@@ -28,6 +30,8 @@ class TestGemCommandsFetchCommand < Gem: https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/rubygems/test_gem_commands_fetch_command.rb#L30
 
     assert_path_exists(File.join(@tempdir, @a2.file_name),
                        "#{@a2.full_name} not fetched")
+    refute_path_exists File.join(@tempdir, 'cache'),
+                       'gem repository directories must not be created'
   end
 
   def test_execute_prerelease

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r39606,39609


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

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