Merge RubyGems-3.3.20 and Bundler-2.3.20

This commit is contained in:
Hiroshi SHIBATA 2022-08-22 11:50:00 +09:00 committed by nagachika
parent 44c926f3a9
commit 522b75f1b6
135 changed files with 1131 additions and 613 deletions

View file

@ -152,7 +152,7 @@ class Gem::Commands::CertCommand < Gem::Command
def build_cert(email, key) # :nodoc:
expiration_length_days = options[:expiration_length_days] ||
Gem.configuration.cert_expiration_length_days
Gem.configuration.cert_expiration_length_days
cert = Gem::Security.create_cert_email(
email,

View file

@ -149,7 +149,7 @@ If no gems are named all gems in GEM_HOME are cleaned.
@primary_gems = {}
Gem::Specification.each do |spec|
if @primary_gems[spec.name].nil? or
if @primary_gems[spec.name].nil? ||
@primary_gems[spec.name].version < spec.version
@primary_gems[spec.name] = spec
end

View file

@ -77,7 +77,7 @@ prefix or only the files that are requireable.
gem_contents name
end
terminate_interaction 1 unless found or names.length > 1
terminate_interaction 1 unless found || names.length > 1
end
end

View file

@ -77,7 +77,7 @@ use with other commands.
name_matches = name_pattern ? name_pattern =~ spec.name : true
version_matches = requirement.satisfied_by?(spec.version)
name_matches and version_matches
name_matches && version_matches
}.map(&:to_spec)
end
@ -133,7 +133,7 @@ use with other commands.
end
def ensure_local_only_reverse_dependencies # :nodoc:
if options[:reverse_dependencies] and remote? and not local?
if options[:reverse_dependencies] && remote? && !local?
alert_error "Only reverse dependencies for local gems are supported."
terminate_interaction 1
end
@ -182,7 +182,7 @@ use with other commands.
sp.dependencies.each do |dep|
dep = Gem::Dependency.new(*dep) unless Gem::Dependency === dep
if spec.name == dep.name and
if spec.name == dep.name &&
dep.requirement.satisfied_by?(spec.version)
result << [sp.full_name, dep]
end
@ -197,7 +197,7 @@ use with other commands.
def name_pattern(args)
return if args.empty?
if args.length == 1 and args.first =~ /\A(.*)(i)?\z/m
if args.length == 1 && args.first =~ /\A(.*)(i)?\z/m
flags = $2 ? Regexp::IGNORECASE : nil
Regexp.new $1, flags
else

View file

@ -52,8 +52,8 @@ then repackaging it.
end
def check_version # :nodoc:
if options[:version] != Gem::Requirement.default and
get_all_gem_names.size > 1
if options[:version] != Gem::Requirement.default &&
get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
" version requirements using `gem fetch 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
terminate_interaction 1

View file

@ -68,8 +68,8 @@ Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
# This is always true because it's the only way now.
options[:build_modern] = true
if not File.exist?(options[:directory]) or
not File.directory?(options[:directory])
if !File.exist?(options[:directory]) ||
!File.directory?(options[:directory])
alert_error "unknown directory name #{options[:directory]}."
terminate_interaction 1
else

View file

@ -46,8 +46,8 @@ class Gem::Commands::InstallCommand < Gem::Command
def defaults_str # :nodoc:
"--both --version '#{Gem::Requirement.default}' --no-force\n" +
"--install-dir #{Gem.dir} --lock\n" +
install_update_defaults_str
"--install-dir #{Gem.dir} --lock\n" +
install_update_defaults_str
end
def description # :nodoc:
@ -134,15 +134,15 @@ You can use `i` command instead of `install`.
end
def check_install_dir # :nodoc:
if options[:install_dir] and options[:user_install]
if options[:install_dir] && options[:user_install]
alert_error "Use --install-dir or --user-install but not both"
terminate_interaction 1
end
end
def check_version # :nodoc:
if options[:version] != Gem::Requirement.default and
get_all_gem_names.size > 1
if options[:version] != Gem::Requirement.default &&
get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
" version requirements using `gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
terminate_interaction 1
@ -191,8 +191,8 @@ You can use `i` command instead of `install`.
end
def install_gem(name, version) # :nodoc:
return if options[:conservative] and
not Gem::Dependency.new(name, version).matching_specs.empty?
return if options[:conservative] &&
!Gem::Dependency.new(name, version).matching_specs.empty?
req = Gem::Requirement.create(version)

View file

@ -102,10 +102,10 @@ extensions will be restored.
# `--extensions` must be explicitly given to pristine only gems
# with extensions.
elsif options[:extensions_set] and
options[:extensions] and options[:args].empty?
elsif options[:extensions_set] &&
options[:extensions] && options[:args].empty?
Gem::Specification.select do |spec|
spec.extensions and not spec.extensions.empty?
spec.extensions && !spec.extensions.empty?
end
else
get_all_gem_names.sort.map do |gem_name|
@ -135,14 +135,14 @@ extensions will be restored.
end
end
unless spec.extensions.empty? or options[:extensions] or options[:only_executables] or options[:only_plugins]
unless spec.extensions.empty? || options[:extensions] || options[:only_executables] || options[:only_plugins]
say "Skipped #{spec.full_name}, it needs to compile an extension"
next
end
gem = spec.cache_file
unless File.exist? gem or options[:only_executables] or options[:only_plugins]
unless File.exist?(gem) || options[:only_executables] || options[:only_plugins]
require_relative "../remote_fetcher"
say "Cached gem for #{spec.full_name} not found, attempting to fetch..."

View file

@ -329,9 +329,9 @@ By default, this RubyGems will install gem as:
# ignore
end
if File.writable? gem_doc_dir and
(not File.exist? rubygems_doc_dir or
File.writable? rubygems_doc_dir)
if File.writable?(gem_doc_dir) &&
(!File.exist?(rubygems_doc_dir) ||
File.writable?(rubygems_doc_dir))
say "Removing old RubyGems RDoc and ri" if @verbose
Dir[File.join(Gem.dir, "doc", "rubygems-[0-9]*")].each do |dir|
rm_rf dir
@ -559,7 +559,7 @@ abort "#{deprecation_message}"
history_string = ""
until versions.length == 0 or
until versions.length == 0 ||
versions.shift <= options[:previous_version] do
history_string += version_lines.shift + text.shift
end

View file

@ -82,7 +82,7 @@ Do you want to add this source?
def check_rubygems_https(source_uri) # :nodoc:
uri = URI source_uri
if uri.scheme and uri.scheme.downcase == "http" and
if uri.scheme && uri.scheme.downcase == "http" &&
uri.host.downcase == "rubygems.org"
question = <<-QUESTION.chomp
https://rubygems.org is recommended for security over #{uri}
@ -215,9 +215,9 @@ To remove a source use the --remove argument:
def remove_cache_file(desc, path) # :nodoc:
FileUtils.rm_rf path
if not File.exist?(path)
if !File.exist?(path)
say "*** Removed #{desc} source cache ***"
elsif not File.writable?(path)
elsif !File.writable?(path)
say "*** Unable to remove #{desc} source cache (write protected) ***"
else
say "*** Unable to remove #{desc} source cache ***"

View file

@ -88,7 +88,7 @@ Specific fields in the specification can be extracted in YAML format:
raise Gem::CommandLineError, "Unsupported version type: '#{v}'"
end
if !req.none? and options[:all]
if !req.none? && options[:all]
alert_error "Specify --all or -v, not both"
terminate_interaction 1
end
@ -102,7 +102,7 @@ Specific fields in the specification can be extracted in YAML format:
field = get_one_optional_argument
raise Gem::CommandLineError, "--ruby and FIELD are mutually exclusive" if
field and options[:format] == :ruby
field && options[:format] == :ruby
if local?
if File.exist? gem

View file

@ -96,7 +96,7 @@ class Gem::Commands::UninstallCommand < Gem::Command
def defaults_str # :nodoc:
"--version '#{Gem::Requirement.default}' --no-force " +
"--user-install"
"--user-install"
end
def description # :nodoc:
@ -114,8 +114,8 @@ that is a dependency of an existing gem. You can use the
end
def check_version # :nodoc:
if options[:version] != Gem::Requirement.default and
get_all_gem_names.size > 1
if options[:version] != Gem::Requirement.default &&
get_all_gem_names.size > 1
alert_error "Can't use --version with multiple gems. You can specify multiple gems with" \
" version requirements using `gem uninstall 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'`"
terminate_interaction 1
@ -125,7 +125,7 @@ that is a dependency of an existing gem. You can use the
def execute
check_version
if options[:all] and not options[:args].empty?
if options[:all] && !options[:args].empty?
uninstall_specific
elsif options[:all]
uninstall_all

View file

@ -56,7 +56,7 @@ class Gem::Commands::UpdateCommand < Gem::Command
def defaults_str # :nodoc:
"--no-force --install-dir #{Gem.dir}\n" +
install_update_defaults_str
install_update_defaults_str
end
def description # :nodoc:
@ -155,7 +155,7 @@ command to remove old versions.
Gem::Specification.dirs = Gem.user_dir if options[:user_install]
Gem::Specification.each do |spec|
if hig[spec.name].nil? or hig[spec.name].version < spec.version
if hig[spec.name].nil? || hig[spec.name].version < spec.version
hig[spec.name] = spec
end
end
@ -292,8 +292,8 @@ command to remove old versions.
args << "--no-document" unless options[:document].include?("rdoc") || options[:document].include?("ri")
args << "--no-format-executable" if options[:no_format_executable]
args << "--previous-version" << Gem::VERSION if
options[:system] == true or
Gem::Version.new(options[:system]) >= Gem::Version.new(2)
options[:system] == true ||
Gem::Version.new(options[:system]) >= Gem::Version.new(2)
args
end
@ -301,7 +301,7 @@ command to remove old versions.
result = []
highest_installed_gems.each do |l_name, l_spec|
next if not gem_names.empty? and
next if !gem_names.empty? &&
gem_names.none? {|name| name == l_spec.name }
highest_remote_tup = highest_remote_name_tuple l_spec

View file

@ -71,7 +71,7 @@ requiring to see why it does not behave as you expect.
dirs.each do |dir|
Gem.suffixes.each do |ext|
full_path = File.join dir, "#{package_name}#{ext}"
if File.exist? full_path and not File.directory? full_path
if File.exist?(full_path) && !File.directory?(full_path)
result << full_path
return result unless options[:show_all]
end