Merge rubygems-3.0.0.beta3.

* [GSoC] Multi-factor feature for RubyGems https://github.com/rubygems/rubygems/pull/2369

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2018-12-01 11:01:00 +00:00
parent 5cae104e51
commit 7a46a3b941
9 changed files with 169 additions and 12 deletions

View file

@ -33,6 +33,7 @@ command. For further discussion see the help for the yank command.
add_proxy_option
add_key_option
add_otp_option
add_option('--host HOST',
'Push to another gemcutter-compatible host',
@ -113,11 +114,10 @@ You can upgrade or downgrade to the latest release version with:
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
request.add_field "Content-Type", "application/octet-stream"
request.add_field "Authorization", api_key
response = send_push_request(name, args)
if need_otp? response
response = send_push_request(name, args, true)
end
with_response response
@ -125,6 +125,16 @@ You can upgrade or downgrade to the latest release version with:
private
def send_push_request(name, args, use_otp = false)
rubygems_api_request(*args) do |request|
request.body = Gem.read_binary name
request.add_field "Content-Length", request.body.size
request.add_field "Content-Type", "application/octet-stream"
request.add_field "Authorization", api_key
request.add_field "OTP", options[:otp] if use_otp
end
end
def get_hosts_for(name)
gem_metadata = Gem::Package.new(name).spec.metadata