aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-12-18 12:13:33 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-12-18 13:33:18 +0900
commit0e40cc9b194a5e46024d32b85a61e651372a65cb (patch)
treed91f781ca34d78897d8cea9fb3403e47f891df5a /lib
parent34f06062174882a98ebef998c50ad8d4f7fc0f2e (diff)
downloadruby-0e40cc9b194a5e46024d32b85a61e651372a65cb.tar.gz
Merge RubyGems 3.2.2 and Bundler 2.2.2
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli/install.rb19
-rw-r--r--lib/bundler/resolver.rb2
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/owner_command.rb1
-rw-r--r--lib/rubygems/commands/push_command.rb1
-rw-r--r--lib/rubygems/commands/yank_command.rb1
-rw-r--r--lib/rubygems/ext/rake_builder.rb2
-rw-r--r--lib/rubygems/gemcutter_utilities.rb35
-rw-r--r--lib/rubygems/test_utilities.rb11
10 files changed, 45 insertions, 31 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index edf86fe1ba..c702eb14d1 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -152,18 +152,27 @@ module Bundler
check_for_group_conflicts_in_cli_options
+ Bundler.settings.set_command_option :with, nil if options[:with] == []
+ Bundler.settings.set_command_option :without, nil if options[:without] == []
+
with = options.fetch(:with, [])
with |= Bundler.settings[:with].map(&:to_s)
with -= options[:without] if options[:without]
- with = nil if options[:with] == []
without = options.fetch(:without, [])
without |= Bundler.settings[:without].map(&:to_s)
without -= options[:with] if options[:with]
- without = nil if options[:without] == []
- Bundler.settings.set_command_option :without, without
- Bundler.settings.set_command_option :with, with
+ options[:with] = with
+ options[:without] = without
+
+ unless Bundler.settings[:without] == options[:without] && Bundler.settings[:with] == options[:with]
+ # need to nil them out first to get around validation for backwards compatibility
+ Bundler.settings.set_command_option :without, nil
+ Bundler.settings.set_command_option :with, nil
+ Bundler.settings.set_command_option :without, options[:without] - options[:with]
+ Bundler.settings.set_command_option :with, options[:with]
+ end
end
def normalize_settings
@@ -190,7 +199,7 @@ module Bundler
Bundler.settings.set_command_option_if_given :clean, options["clean"]
- normalize_groups if options[:without] || options[:with]
+ normalize_groups
options[:force] = options[:redownload]
end
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 4bbcbd1162..636dc8af46 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -155,6 +155,8 @@ module Bundler
search.each do |sg|
next unless sg.for?(platform)
sg_all_platforms = sg.copy_for(self.class.sort_platforms(@platforms).reverse)
+ next unless sg_all_platforms
+
selected_sgs << sg_all_platforms
next if sg_all_platforms.activated_platforms == [Gem::Platform::RUBY]
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index b8b331d85e..c730934258 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.2.1".freeze
+ VERSION = "2.2.2".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 7596585482..5da8b6904b 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = "3.2.1".freeze
+ VERSION = "3.2.2".freeze
end
# Must be first since it unloads the prelude from 1.9.2
diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb
index 46172854cf..dd49027469 100644
--- a/lib/rubygems/commands/owner_command.rb
+++ b/lib/rubygems/commands/owner_command.rb
@@ -105,7 +105,6 @@ permission to.
rubygems_api_request method, "api/v1/gems/#{name}/owners", scope: get_owner_scope(method: method) do |request|
request.set_form_data 'email' => owner
request.add_field "Authorization", api_key
- request.add_field "OTP", options[:otp] if options[:otp]
end
end
diff --git a/lib/rubygems/commands/push_command.rb b/lib/rubygems/commands/push_command.rb
index 8885269ecb..1a9a1932f8 100644
--- a/lib/rubygems/commands/push_command.rb
+++ b/lib/rubygems/commands/push_command.rb
@@ -91,7 +91,6 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
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 options[:otp]
end
end
diff --git a/lib/rubygems/commands/yank_command.rb b/lib/rubygems/commands/yank_command.rb
index 0e08bbfd5d..7e8b66b300 100644
--- a/lib/rubygems/commands/yank_command.rb
+++ b/lib/rubygems/commands/yank_command.rb
@@ -74,7 +74,6 @@ data you will need to change them immediately and yank your gem.
name = get_one_gem_name
response = rubygems_api_request(method, api, host, scope: get_yank_scope) do |request|
request.add_field("Authorization", api_key)
- request.add_field("OTP", options[:otp]) if options[:otp]
data = {
'gem_name' => name,
diff --git a/lib/rubygems/ext/rake_builder.rb b/lib/rubygems/ext/rake_builder.rb
index 34c3922f2f..64a6c0eb80 100644
--- a/lib/rubygems/ext/rake_builder.rb
+++ b/lib/rubygems/ext/rake_builder.rb
@@ -19,7 +19,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
rake = rake.shellsplit
else
begin
- rake = [Gem.ruby, "-I#{File.expand_path("..", __dir__)}", "-rrubygems", Gem.bin_path('rake', 'rake')]
+ rake = [Gem.ruby, "-I#{File.expand_path("../..", __dir__)}", "-rrubygems", Gem.bin_path('rake', 'rake')]
rescue Gem::Exception
rake = [Gem.default_exec_format % 'rake']
end
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index d021f47e24..8751a79d63 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -94,20 +94,16 @@ module Gem::GemcutterUtilities
end
uri = URI.parse "#{self.host}/#{path}"
-
- request_method = Net::HTTP.const_get method.to_s.capitalize
- response = Gem::RemoteFetcher.fetcher.request(uri, request_method, &block)
+ response = request_with_otp(method, uri, &block)
if mfa_unauthorized?(response)
- response = Gem::RemoteFetcher.fetcher.request(uri, request_method) do |req|
- req.add_field "OTP", get_otp
- block.call(req)
- end
+ ask_otp
+ response = request_with_otp(method, uri, &block)
end
if api_key_forbidden?(response)
update_scope(scope)
- Gem::RemoteFetcher.fetcher.request(uri, request_method, &block)
+ request_with_otp(method, uri, &block)
else
response
end
@@ -117,11 +113,6 @@ module Gem::GemcutterUtilities
response.kind_of?(Net::HTTPUnauthorized) && response.body.start_with?('You have enabled multifactor authentication')
end
- def get_otp
- say 'You have enabled multi-factor authentication. Please enter OTP code.'
- ask 'Code: '
- end
-
def update_scope(scope)
sign_in_host = self.host
pretty_host = pretty_host(sign_in_host)
@@ -135,7 +126,7 @@ module Gem::GemcutterUtilities
response = rubygems_api_request(:put, "api/v1/api_key",
sign_in_host, scope: scope) do |request|
request.basic_auth email, password
- request.add_field "OTP", options[:otp] if options[:otp]
+ request["OTP"] = options[:otp] if options[:otp]
request.body = URI.encode_www_form({:api_key => api_key }.merge(update_scope_params))
end
@@ -168,7 +159,7 @@ module Gem::GemcutterUtilities
response = rubygems_api_request(:post, "api/v1/api_key",
sign_in_host, scope: scope) do |request|
request.basic_auth email, password
- request.add_field "OTP", options[:otp] if options[:otp]
+ request["OTP"] = options[:otp] if options[:otp]
request.body = URI.encode_www_form({ name: key_name }.merge(scope_params))
end
@@ -229,6 +220,20 @@ module Gem::GemcutterUtilities
private
+ def request_with_otp(method, uri, &block)
+ request_method = Net::HTTP.const_get method.to_s.capitalize
+
+ Gem::RemoteFetcher.fetcher.request(uri, request_method) do |req|
+ req["OTP"] = options[:otp] if options[:otp]
+ block.call(req)
+ end
+ end
+
+ def ask_otp
+ say 'You have enabled multi-factor authentication. Please enter OTP code.'
+ options[:otp] = ask 'Code: '
+ end
+
def pretty_host(host)
if Gem::DEFAULT_HOST == host
'RubyGems.org'
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 3bbe68ca0c..1371ae9b14 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -38,7 +38,7 @@ class Gem::FakeFetcher
@paths = []
end
- def find_data(path, nargs = 3)
+ def find_data(path)
return Gem.read_binary path.path if URI === path and 'file' == path.scheme
if URI === path and "URI::#{path.scheme.upcase}" != path.class.name
@@ -54,10 +54,11 @@ class Gem::FakeFetcher
raise Gem::RemoteFetcher::FetchError.new("no data for #{path}", path)
end
- data = @data[path]
-
- data.flatten! and return data.shift(nargs) if data.respond_to?(:flatten!)
- data
+ if @data[path].kind_of?(Array) && @data[path].first.kind_of?(Array)
+ @data[path].shift
+ else
+ @data[path]
+ end
end
def fetch_path(path, mtime = nil, head = false)