diff options
Diffstat (limited to 'lib/rubygems/commands/push_command.rb')
-rw-r--r-- | lib/rubygems/commands/push_command.rb | 13 |
1 files changed, 12 insertions, 1 deletions
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 |