diff options
author | Hiroshi SHIBATA <[email protected]> | 2021-07-07 14:07:29 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2021-07-07 15:31:52 +0900 |
commit | c082c6eb7c786a432bea23cf78839f64585cb630 () | |
tree | e3c608264fe03645e905fe7284d713cff87b87dd /lib/rubygems | |
parent | 6e2240a2f954c84ed12357382c9c065ae4b91e11 (diff) |
Sync RubyGems and Bundler with upstream
Notes: Merged: https://.com/ruby/ruby/pull/4634
-rw-r--r-- | lib/rubygems/core_ext/tcpsocket_init.rb | 4 | ||||
-rw-r--r-- | lib/rubygems/deprecate.rb | 59 | ||||
-rw-r--r-- | lib/rubygems/gemcutter_utilities.rb | 13 | ||||
-rw-r--r-- | lib/rubygems/installer.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/remote_fetcher.rb | 15 | ||||
-rw-r--r-- | lib/rubygems/request/connection_pools.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/request/http_pool.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/request_set.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/specification.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/uri_parser.rb | 8 | ||||
-rw-r--r-- | lib/rubygems/uri_parsing.rb | 23 | ||||
-rw-r--r-- | lib/rubygems/user_interaction.rb | 2 |
12 files changed, 85 insertions, 49 deletions
@@ -11,10 +11,10 @@ module CoreExtensions IPV4_DELAY_SECONDS = 0.1 def initialize(host, serv, *rest) - mutex = Mutex.new addrs = [] threads = [] - cond_var = ConditionVariable.new Addrinfo.foreach(host, serv, nil, :STREAM) do |addr| Thread.report_on_exception = false if defined? Thread.report_on_exception = () @@ -1,23 +1,70 @@ # frozen_string_literal: true ## -# Provides a single method +deprecate+ to be used to declare when -# something is going away. # # class Legacy -# def self.klass_method # # ... # end # -# def instance_method # # ... # end # # extend Gem::Deprecate -# deprecate :instance_method, "X.z", 2011, 4 # # class << self # extend Gem::Deprecate -# deprecate :klass_method, :none, 2011, 4 # end # end @@ -52,6 +52,13 @@ module Gem::GemcutterUtilities end ## # The host to connect to either from the RUBYGEMS_HOST environment variable # or from the user's configuration @@ -126,7 +133,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["OTP"] = options[:otp] if options[:otp] request.body = URI.encode_www_form({:api_key => api_key }.merge(update_scope_params)) end @@ -159,7 +166,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["OTP"] = options[:otp] if options[:otp] request.body = URI.encode_www_form({ name: key_name }.merge(scope_params)) end @@ -224,7 +231,7 @@ module Gem::GemcutterUtilities 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 @@ -68,7 +68,7 @@ class Gem::Installer @path_warning = false - @install_lock = Mutex.new class << self ## @@ -4,7 +4,7 @@ require 'rubygems/request' require 'rubygems/request/connection_pools' require 'rubygems/s3_uri_signer' require 'rubygems/uri_formatter' -require 'rubygems/uri_parsing' require 'rubygems/user_interaction' require 'resolv' @@ -14,15 +14,12 @@ require 'resolv' class Gem::RemoteFetcher include Gem::UserInteraction - include Gem::UriParsing ## # A FetchError exception wraps up the various possible IO and HTTP failures # that could happen while downloading from the internet. class FetchError < Gem::Exception - include Gem::UriParsing - ## # The URI which was being accessed when the exception happened. @@ -31,7 +28,7 @@ class Gem::RemoteFetcher def initialize(message, uri) super message - uri = parse_uri(uri) @original_uri = uri.dup @@ -88,7 +85,7 @@ class Gem::RemoteFetcher @proxy = proxy @pools = {} - @pool_lock = Mutex.new @cert_files = Gem::Request.get_cert_files @headers = headers @@ -133,7 +130,7 @@ class Gem::RemoteFetcher require "fileutils" FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir - source_uri = parse_uri(source_uri) scheme = source_uri.scheme @@ -228,7 +225,7 @@ class Gem::RemoteFetcher unless location = response['Location'] raise FetchError.new("redirecting but no redirect location was given", uri) end - location = parse_uri location if https?(uri) && !https?(location) raise FetchError.new("redirecting to non-https resource: #{location}", uri) @@ -246,7 +243,7 @@ class Gem::RemoteFetcher # Downloads +uri+ and returns it as a String. def fetch_path(uri, mtime = nil, head = false) - uri = parse_uri uri unless uri.scheme raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}" @@ -11,7 +11,7 @@ class Gem::Request::ConnectionPools # :nodoc: @proxy_uri = proxy_uri @cert_files = cert_files @pools = {} - @pool_mutex = Mutex.new end def pool_for(uri) @@ -12,7 +12,7 @@ class Gem::Request::HTTPPool # :nodoc: @http_args = http_args @cert_files = cert_files @proxy_uri = proxy_uri - @queue = SizedQueue.new 1 @queue << nil end @@ -151,7 +151,7 @@ class Gem::RequestSet @prerelease = options[:prerelease] requests = [] - download_queue = Queue.new # Create a thread-safe list of gems to download sorted_requests.each do |req| @@ -105,7 +105,7 @@ class Gem::Specification < Gem::BasicSpecification # rubocop:disable Style/MutableConstant LOAD_CACHE = {} # :nodoc: # rubocop:enable Style/MutableConstant - LOAD_CACHE_MUTEX = Mutex.new private_constant :LOAD_CACHE if defined? private_constant @@ -5,10 +5,18 @@ # class Gem::UriParser ## # Parses the #uri, raising if it's invalid def parse!(uri) raise URI::InvalidURIError unless uri # Always escape URI's to deal with potential spaces and such @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -require "rubygems/uri_parser" - -module Gem::UriParsing - - def parse_uri(source_uri) - return source_uri unless source_uri.is_a?(String) - - uri_parser.parse(source_uri) - end - - private :parse_uri - - def uri_parser - require "uri" - - Gem::UriParser.new - end - - private :uri_parser - -end @@ -543,7 +543,7 @@ class Gem::StreamUI # A progress reporter that behaves nicely with threaded downloading. class ThreadedDownloadReporter - MUTEX = Mutex.new ## # The current file name being displayed |