Index: NEWS =================================================================== --- NEWS (revision 42940) +++ NEWS (working copy) @@ -461,14 +461,15 @@ with all sufficient information, see the XML declaration is used for XML document encoding. * RubyGems + * Updated to 2.0.9. + + http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.0.9+%2F+2013-09-13 + for release notes. + * Updated to 2.0.8. This fixes CVE-2013-4287: http://rubygems.rubyforge.org/rubygems-update/CVE-2013-4287_txt.html - * Updated to 2.0.3. See - http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.0.3+%2F+2012-03-1 - for release notes. - * Updated to 2.0.0 RubyGems 2.0.0 features the following improvements: Index: lib/rubygems/commands/fetch_command.rb =================================================================== --- lib/rubygems/commands/fetch_command.rb (revision 42940) +++ lib/rubygems/commands/fetch_command.rb (working copy) @@ -43,12 +43,13 @@ class Gem::Commands::FetchCommand < Gem: dep.prerelease = options[:prerelease] specs_and_sources, errors = Gem::SpecFetcher.fetcher.spec_for_dependency dep + if platform then filtered = specs_and_sources.select { |s,| s.platform == platform } specs_and_sources = filtered unless filtered.empty? end - spec, source = specs_and_sources.sort_by { |s,| s.version }.first + spec, source = specs_and_sources.max_by { |s,| s.version } if spec.nil? then show_lookup_failure gem_name, version, errors, options[:domain] Index: lib/rubygems/gemcutter_utilities.rb =================================================================== --- lib/rubygems/gemcutter_utilities.rb (revision 42940) +++ lib/rubygems/gemcutter_utilities.rb (working copy) @@ -27,7 +27,8 @@ module Gem::GemcutterUtilities end end - def sign_in sign_in_host = self.host + def sign_in sign_in_host = nil + sign_in_host ||= self.host return if Gem.configuration.rubygems_api_key pretty_host = if Gem::DEFAULT_HOST == sign_in_host then Index: lib/rubygems.rb =================================================================== --- lib/rubygems.rb (revision 42940) +++ lib/rubygems.rb (working copy) @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = '2.0.8' + VERSION = '2.0.9' end # Must be first since it unloads the prelude from 1.9.2 Index: test/rubygems/test_gem_commands_fetch_command.rb =================================================================== --- test/rubygems/test_gem_commands_fetch_command.rb (revision 42940) +++ test/rubygems/test_gem_commands_fetch_command.rb (working copy) @@ -34,6 +34,32 @@ class TestGemCommandsFetchCommand < Gem: 'gem repository directories must not be created' end + def test_execute_latest + util_setup_fake_fetcher + util_setup_spec_fetcher @a1, @a2 + + @fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] = + File.read(@a1.cache_file) + @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] + @cmd.options[:version] = req('>= 0.1') + + use_ui @ui do + Dir.chdir @tempdir do + @cmd.execute + end + end + + 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 util_setup_fake_fetcher true util_clear_gems @@ -53,8 +79,8 @@ class TestGemCommandsFetchCommand < Gem: end end - assert_path_exists(File.join(@tempdir, @a2_pre.file_name), - "#{@a2_pre.full_name} not fetched") + assert_path_exists(File.join(@tempdir, @a2.file_name), + "#{@a2.full_name} not fetched") end def test_execute_specific_prerelease Index: test/rubygems/test_gem_gemcutter_utilities.rb =================================================================== --- test/rubygems/test_gem_gemcutter_utilities.rb (revision 42940) +++ test/rubygems/test_gem_gemcutter_utilities.rb (working copy) @@ -101,7 +101,7 @@ class TestGemGemcutterUtilities < Gem::T def test_sign_in_with_host api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' - util_sign_in [api_key, 200, 'OK'], 'http://example.com', :param + util_sign_in [api_key, 200, 'OK'], 'http://example.com', ['http://example.com'] assert_match "Enter your http://example.com credentials.", @sign_in_ui.output @@ -112,6 +112,20 @@ class TestGemGemcutterUtilities < Gem::T assert_equal api_key, credentials[:rubygems_api_key] end + def test_sign_in_with_host_nil + api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' + + util_sign_in [api_key, 200, 'OK'], nil, [nil] + + assert_match "Enter your RubyGems.org credentials.", + @sign_in_ui.output + assert @fetcher.last_request["authorization"] + assert_match %r{Signed in.}, @sign_in_ui.output + + credentials = YAML.load_file Gem.configuration.credentials_path + assert_equal api_key, credentials[:rubygems_api_key] + end + def test_sign_in_with_host_ENV api_key = 'a5fdbb6ba150cbb83aad2bb2fede64cf040453903' util_sign_in [api_key, 200, 'OK'], 'http://example.com' @@ -163,14 +177,14 @@ class TestGemGemcutterUtilities < Gem::T assert_match %r{Access Denied.}, @sign_in_ui.output end - def util_sign_in response, host = nil, style = :ENV + def util_sign_in response, host = nil, args = [] skip 'Always uses $stdin on windows' if Gem.win_platform? email = 'you@example.com' password = 'secret' if host - ENV['RUBYGEMS_HOST'] = host if style == :ENV + ENV['RUBYGEMS_HOST'] = host else host = Gem.host end @@ -182,8 +196,8 @@ class TestGemGemcutterUtilities < Gem::T @sign_in_ui = Gem::MockGemUi.new "#{email}\n#{password}\n" use_ui @sign_in_ui do - if style == :param then - @cmd.sign_in host + if args.length > 0 then + @cmd.sign_in(*args) else @cmd.sign_in end @@ -209,4 +223,3 @@ class TestGemGemcutterUtilities < Gem::T end end -