Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ lib/rubygems/vendor/net-http/lib/net/http/response.rb
lib/rubygems/vendor/net-http/lib/net/http/responses.rb
lib/rubygems/vendor/net-http/lib/net/http/status.rb
lib/rubygems/vendor/net-http/lib/net/https.rb
lib/rubygems/vendor/net-protocol/LICENSE.txt
lib/rubygems/vendor/net-protocol/COPYING
lib/rubygems/vendor/net-protocol/lib/net/protocol.rb
lib/rubygems/vendor/optparse/COPYING
lib/rubygems/vendor/optparse/lib/optionparser.rb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def initialize(options = {}, &block)
end

def with(options = {})
# We need to manage exception handling manually here in order
# to work correctly with `Gem::Timeout.timeout` and `Thread#raise`.
# Otherwise an interrupted Thread can leak connections.
Thread.handle_interrupt(Exception => :never) do
conn = checkout(options)
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ def push(obj, options = {})
# immediately returned. If no connection is available within the given
# timeout a Bundler::ConnectionPool::TimeoutError is raised.
#
# +:timeout+ is the only checked entry in +options+ and is preferred over
# the +timeout+ argument (which will be removed in a future release). Other
# options may be used by subclasses that extend TimedStack.
# @option options [Float] :timeout (0.5) Wait this many seconds for an available entry
# @option options [Class] :exception (Bundler::ConnectionPool::TimeoutError) Exception class to raise
# if an entry was not available within the timeout period. Use `exception: false` to return nil.
#
# The +timeout+ argument will be removed in 3.0.
# Other options may be used by subclasses that extend TimedStack.
def pop(timeout = 0.5, options = {})
options, timeout = timeout, 0.5 if Hash === timeout
timeout = options.fetch :timeout, timeout
Expand All @@ -73,7 +76,14 @@ def pop(timeout = 0.5, options = {})
return connection if connection

to_wait = deadline - current_time
raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available" if to_wait <= 0
if to_wait <= 0
exc = options.fetch(:exception, Bundler::ConnectionPool::TimeoutError)
if exc
raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available"
else
return nil
end
end
@resource.wait(@mutex, to_wait)
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Bundler::ConnectionPool
VERSION = "2.5.4"
VERSION = "2.5.5"
end
83 changes: 54 additions & 29 deletions bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
#
module Bundler::FileUtils
# The version number.
VERSION = "1.8.0"
VERSION = "1.8.1"

def self.private_module_function(name) #:nodoc:
module_function name
Expand Down Expand Up @@ -279,38 +279,67 @@ def remove_trailing_slash(dir) #:nodoc:
end
private_module_function :remove_trailing_slash

# :markup: markdown
#
# Creates directories at the paths in the given +list+
# (a single path or an array of paths);
# returns +list+ if it is an array, <tt>[list]</tt> otherwise.
# call-seq:
# Bundler::FileUtils.mkdir(*paths, mode: 0775, noop: nil, verbose: nil) -> array_of_paths or nil
#
# Argument +list+ or its elements
# should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments].
# Argument `paths` may be one path or an array of paths;
# each must be {interpretable as a path}[rdoc-ref:FileUtils@Path+Arguments].
#
# With no keyword arguments, creates a directory at each +path+ in +list+
# by calling: <tt>Dir.mkdir(path, mode)</tt>;
# see {Dir.mkdir}[https://docs.ruby-lang.org/en/master/Dir.html#method-c-mkdir]:
# By default, creates a directory entry at each of the given `paths`;
# each directory has permissions `0775`;
# returns an array of the paths:
#
# Bundler::FileUtils.mkdir(%w[tmp0 tmp1]) # => ["tmp0", "tmp1"]
# Bundler::FileUtils.mkdir('tmp4') # => ["tmp4"]
# ```ruby
# Bundler::FileUtils.mkdir('foo') # => ["foo"]
# Bundler::FileUtils.mkdir(%w[bar baz]) # => ["bar", "baz"]
# File.stat(Dir.new('foo')).mode.to_s(8) # => "40775"
# File.stat(Dir.new('bar')).mode.to_s(8) # => "40775"
# File.stat(Dir.new('baz')).mode.to_s(8) # => "40775"
# Bundler::FileUtils.rmdir(%w[foo bar baz]) # => ["foo", "bar", "baz"]
# ```
#
# Keyword arguments:
# Raises an exception if for any reason a directory cannot be created;
# a common reason is that the directory already exists.
#
# - <tt>mode: <i>mode</i></tt> - also calls <tt>File.chmod(mode, path)</tt>;
# see {File.chmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-chmod].
# - <tt>noop: true</tt> - does not create directories.
# - <tt>verbose: true</tt> - prints an equivalent command:
# With keyword argument `mode` given,
# creates directories with the given permissions:
#
# Bundler::FileUtils.mkdir(%w[tmp0 tmp1], verbose: true)
# Bundler::FileUtils.mkdir(%w[tmp2 tmp3], mode: 0700, verbose: true)
# ```ruby
# Bundler::FileUtils.mkdir('bar', mode: 0664)
# File.stat(Dir.new('bar')).mode.to_s(8) # => "40664"
# Bundler::FileUtils.rmdir('bar')
# ```
#
# Output:
# With keyword argument `noop` given as `true`,
# does not create directories;
# returns `nil`
#
# ```ruby
# Bundler::FileUtils.mkdir('foo', noop: true) # => nil
# Dir.exist?('foo') # => false
# ```
#
# With keyword argument `verbose` given as `true`,
# prints a shell command:
#
# mkdir tmp0 tmp1
# mkdir -m 700 tmp2 tmp3
# ```ruby
# Bundler::FileUtils.mkdir('foo', verbose: true)
# Bundler::FileUtils.mkdir(%w[bar baz], mode: 0644, verbose: true)
# Bundler::FileUtils.mkdir(%w[bar baz], mode: 0644, verbose: true, noop: true)
# ```
#
# Raises an exception if any path points to an existing
# file or directory, or if for any reason a directory cannot be created.
# Output:
#
# ```text
# mkdir foo
# mkdir -m 644 bar baz
# mkdir -m 644 bar baz
# ```
#
# Note that in the last call above (containing `noop: true`)
# the existence of the directory is not checked.
#
# Related: Bundler::FileUtils.mkdir_p.
#
Expand Down Expand Up @@ -686,7 +715,7 @@ def cp_lr(src, dest, noop: nil, verbose: nil,
# Keyword arguments:
#
# - <tt>force: true</tt> - overwrites +dest+ if it exists.
# - <tt>relative: false</tt> - create links relative to +dest+.
# - <tt>relative: true</tt> - create links relative to +dest+.
# - <tt>noop: true</tt> - does not create links.
# - <tt>verbose: true</tt> - prints an equivalent command:
#
Expand Down Expand Up @@ -754,7 +783,7 @@ def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil
n = real_ddirs.size - i
n -= 1 unless target_directory
link2 = fu_clean_components(*Array.new([n, 0].max, '..'), *real_sdirs[i..-1])
link1 = link2 if link1.size > link2.size
link1 = link2 if !link2.empty? and link1.size > link2.size
end
s = File.join(link1)
fu_output_message [cmd, s, d].flatten.join(' ') if verbose
Expand Down Expand Up @@ -2037,10 +2066,6 @@ def fu_windows?; true end #:nodoc:
def fu_windows?; false end #:nodoc:
end

def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
IO.copy_stream(src, dest)
end

def fu_stream_blksize(*streams) #:nodoc:
streams.each do |s|
next unless s.respond_to?(:stat)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require_relative '../../../../../vendored_net_http'
require_relative '../../../../../vendored_uri'
begin
require 'cgi/escape'
rescue LoadError
require 'cgi/util' # for escaping
end
require 'cgi/escape'
require 'cgi/util' unless defined?(CGI::EscapeExt)
require_relative '../../../../connection_pool/lib/connection_pool'

autoload :OpenSSL, 'openssl'
Expand Down Expand Up @@ -180,7 +177,7 @@ class Gem::Net::HTTP::Persistent
##
# The version of Gem::Net::HTTP::Persistent you are using

VERSION = '4.0.6'
VERSION = '4.0.8'

##
# Error class for errors raised by Gem::Net::HTTP::Persistent. Various
Expand Down Expand Up @@ -475,6 +472,13 @@ def self.detect_idle_timeout uri, max = 10

attr_reader :verify_hostname


##
# Sets whether to ignore end-of-file when reading a response body
# with Content-Length headers.

attr_accessor :ignore_eof

##
# Creates a new Gem::Net::HTTP::Persistent.
#
Expand Down Expand Up @@ -514,6 +518,7 @@ def initialize name: nil, proxy: nil, pool_size: DEFAULT_POOL_SIZE
@max_retries = 1
@socket_options = []
@ssl_generation = 0 # incremented when SSL session variables change
@ignore_eof = nil

@socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
Socket.const_defined? :TCP_NODELAY
Expand Down Expand Up @@ -642,6 +647,7 @@ def connection_for uri
reset connection
end

http.ignore_eof = @ignore_eof if @ignore_eof
http.keep_alive_timeout = @idle_timeout if @idle_timeout
http.max_retries = @max_retries if http.respond_to?(:max_retries=)
http.read_timeout = @read_timeout if @read_timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Gem::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool # :nodoc:
attr_reader :key # :nodoc:

def initialize(options = {}, &block)
super
super(**options, &block)

@available = Gem::Net::HTTP::Persistent::TimedStackMulti.new(@size, &block)
@key = "current-#{@available.object_id}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
class Gem::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::TimedStack # :nodoc:

##
# Detects if Bundler::ConnectionPool 3.0+ is being used (needed for TimedStack subclass compatibility)

CP_USES_KEYWORD_ARGS = Gem::Version.new(Bundler::ConnectionPool::VERSION) >= Gem::Version.new('3.0.0') # :nodoc:

##
# Returns a new hash that has arrays for keys
#
Expand All @@ -11,7 +16,11 @@ def self.hash_of_arrays # :nodoc:
end

def initialize(size = 0, &block)
super
if CP_USES_KEYWORD_ARGS
super(size: size, &block)
else
super(size, &block)
end

@enqueued = 0
@ques = self.class.hash_of_arrays
Expand Down
35 changes: 34 additions & 1 deletion bundler/lib/bundler/vendor/thor/lib/thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def normalize_command_name(meth) #:nodoc:
# alias name.
def find_command_possibilities(meth)
len = meth.to_s.length
possibilities = all_commands.reject { |_k, c| c.hidden? }.merge(map).keys.select { |n| meth == n[0, len] }.sort
possibilities = all_commands.reject {|k, v| v.is_a?(HiddenCommand) }.merge(map).keys.select { |n| meth == n[0, len] }.sort
unique_possibilities = possibilities.map { |k| map[k] || k }.uniq

if possibilities.include?(meth)
Expand Down Expand Up @@ -671,4 +671,37 @@ def help(command = nil, subcommand = false)
self.class.help(shell, subcommand)
end
end

map TREE_MAPPINGS => :tree

desc "tree", "Print a tree of all available commands"
def tree
build_command_tree(self.class, "")
end

private

def build_command_tree(klass, indent)
# Print current class name if it's not the root Bundler::Thor class
unless klass == Bundler::Thor
say "#{indent}#{klass.namespace || 'default'}", :blue
indent = "#{indent} "
end

# Print all commands for this class
visible_commands = klass.commands.reject { |_, cmd| cmd.hidden? || cmd.name == "help" }
commands_count = visible_commands.count
visible_commands.sort.each_with_index do |(command_name, command), i|
description = command.description.split("\n").first || ""
icon = i == (commands_count - 1) ? "└─" : "├─"
say "#{indent}#{icon} ", nil, false
say command_name, :green, false
say " (#{description})" unless description.empty?
end

# Print all subcommands (from registered Bundler::Thor subclasses)
klass.subcommand_classes.each do |_, subclass|
build_command_tree(subclass, indent)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

class Bundler::Thor
module Actions
WARNINGS = {unchanged_no_flag: "File unchanged! Either the supplied flag value not found or the content has already been inserted!"}

# Injects the given content into a file, raising an error if the contents of
# the file are not changed. Different from gsub_file, this method is reversible.
#
# ==== Parameters
# destination<String>:: Relative path to the destination root
# data<String>:: Data to add to the file. Can be given as a block.
# config<Hash>:: give :verbose => false to not log the status and the flag
# for injection (:after or :before) or :force => true for
# insert two or more times the same content.
#
# ==== Examples
#
# insert_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n"
#
# insert_into_file "config/environment.rb", :after => "Rails::Initializer.run do |config|\n" do
# gems = ask "Which gems would you like to add?"
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
# end
#
def insert_into_file!(destination, *args, &block)
data = block_given? ? block : args.shift

config = args.shift || {}
config[:after] = /\z/ unless config.key?(:before) || config.key?(:after)
config = config.merge({error_on_no_change: true})

action InjectIntoFile.new(self, destination, data, config)
end
alias_method :inject_into_file!, :insert_into_file!

# Injects the given content into a file. Different from gsub_file, this
# method is reversible.
#
Expand All @@ -21,8 +53,6 @@ module Actions
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
# end
#
WARNINGS = {unchanged_no_flag: "File unchanged! Either the supplied flag value not found or the content has already been inserted!"}

def insert_into_file(destination, *args, &block)
data = block_given? ? block : args.shift

Expand All @@ -47,6 +77,7 @@ def initialize(base, destination, data, config)

@replacement = data.is_a?(Proc) ? data.call : data
@flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp)
@error_on_no_change = @config.fetch(:error_on_no_change, false)
end

def invoke!
Expand All @@ -59,6 +90,8 @@ def invoke!
if exists?
if replace!(/#{flag}/, content, config[:force])
say_status(:invoke)
elsif @error_on_no_change
raise Bundler::Thor::Error, "The content of #{destination} did not change"
elsif replacement_present?
say_status(:unchanged, color: :blue)
else
Expand Down
3 changes: 2 additions & 1 deletion bundler/lib/bundler/vendor/thor/lib/thor/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class Bundler::Thor
autoload :RakeCompat, File.expand_path("rake_compat", __dir__)
autoload :Group, File.expand_path("group", __dir__)

# Shortcuts for help.
# Shortcuts for help and tree commands.
HELP_MAPPINGS = %w(-h -? --help -D)
TREE_MAPPINGS = %w(-t --tree)

# Bundler::Thor methods that should not be overwritten by the user.
THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root
Expand Down
Loading
Loading