From 9694bb8cac12969300692dac5a1cf7aa4e3a46cd Mon Sep 17 00:00:00 2001 From: drbrain Date: Thu, 29 Nov 2012 06:52:18 +0000 Subject: * lib/rubygems*: Updated to RubyGems 2.0 * test/rubygems*: ditto. * common.mk (prelude): Updated for RubyGems 2.0 source rearrangement. * tool/change_maker.rb: Allow invalid UTF-8 characters in source files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/commands/push_command.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/rubygems/commands/push_command.rb') diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb index a7663edf4a..0667b47dc1 100644 --- a/lib/rubygems/commands/push_command.rb +++ b/lib/rubygems/commands/push_command.rb @@ -1,6 +1,7 @@ require 'rubygems/command' require 'rubygems/local_remote_options' require 'rubygems/gemcutter_utilities' +require 'rubygems/package' class Gem::Commands::PushCommand < Gem::Command include Gem::LocalRemoteOptions @@ -39,13 +40,23 @@ class Gem::Commands::PushCommand < Gem::Command def send_gem name args = [:post, "api/v1/gems"] - args << options[:host] if options[:host] if Gem.latest_rubygems_version < Gem::Version.new(Gem::VERSION) then alert_error "Using beta/unreleased version of rubygems. Not pushing." terminate_interaction 1 end + host = options[:host] + unless host + if gem_data = Gem::Package.new(name) then + host = gem_data.spec.metadata['default_gem_server'] + end + end + + args << host if host + + say "Pushing gem to #{host || Gem.host}..." + response = rubygems_api_request(*args) do |request| request.body = Gem.read_binary name request.add_field "Content-Length", request.body.size -- cgit v1.2.3