ruby-changes:69748
From: Hiroshi <ko1@a...>
Date: Tue, 16 Nov 2021 20:20:19 +0900 (JST)
Subject: [ruby-changes:69748] f3bda8987e (master): Merge the master branch of rubygems repo
https://git.ruby-lang.org/ruby.git/commit/?id=f3bda8987e From f3bda8987ecf78aa260e697232876b35f83b67c3 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Tue, 16 Nov 2021 20:19:13 +0900 Subject: Merge the master branch of rubygems repo Picked from https://github.com/rubygems/rubygems/commit/4b498709a015a94e14a3852a1841a7a3e669133d --- lib/bundler/definition.rb | 48 +- lib/rubygems/command.rb | 8 +- lib/rubygems/commands/cert_command.rb | 12 +- lib/rubygems/commands/setup_command.rb | 4 - lib/rubygems/commands/uninstall_command.rb | 2 +- lib/rubygems/commands/update_command.rb | 2 +- lib/rubygems/ext/cmake_builder.rb | 2 +- lib/rubygems/install_update_options.rb | 4 +- lib/rubygems/installer.rb | 35 +- lib/rubygems/local_remote_options.rb | 6 +- lib/rubygems/optparse.rb | 3 + lib/rubygems/optparse/lib/optionparser.rb | 2 + lib/rubygems/optparse/lib/optparse.rb | 2230 ++++++++++++++++++++ lib/rubygems/optparse/lib/optparse/ac.rb | 54 + lib/rubygems/optparse/lib/optparse/date.rb | 18 + lib/rubygems/optparse/lib/optparse/kwargs.rb | 22 + lib/rubygems/optparse/lib/optparse/shellwords.rb | 7 + lib/rubygems/optparse/lib/optparse/time.rb | 11 + lib/rubygems/optparse/lib/optparse/uri.rb | 7 + lib/rubygems/optparse/lib/optparse/version.rb | 71 + lib/rubygems/security_option.rb | 6 +- lib/rubygems/version_option.rb | 4 +- spec/bundler/commands/exec_spec.rb | 30 + spec/bundler/install/gems/flex_spec.rb | 29 +- test/rubygems/encrypted_private_key.pem | 52 +- test/rubygems/test_gem_command.rb | 2 +- test/rubygems/test_gem_commands_cert_command.rb | 16 +- .../test_gem_commands_uninstall_command.rb | 2 +- test/rubygems/test_gem_commands_yank_command.rb | 2 +- test/rubygems/test_gem_install_update_options.rb | 4 +- 30 files changed, 2580 insertions(+), 115 deletions(-) create mode 100644 lib/rubygems/optparse.rb create mode 100644 lib/rubygems/optparse/lib/optionparser.rb create mode 100644 lib/rubygems/optparse/lib/optparse.rb create mode 100644 lib/rubygems/optparse/lib/optparse/ac.rb create mode 100644 lib/rubygems/optparse/lib/optparse/date.rb create mode 100644 lib/rubygems/optparse/lib/optparse/kwargs.rb create mode 100644 lib/rubygems/optparse/lib/optparse/shellwords.rb create mode 100644 lib/rubygems/optparse/lib/optparse/time.rb create mode 100644 lib/rubygems/optparse/lib/optparse/uri.rb create mode 100644 lib/rubygems/optparse/lib/optparse/version.rb diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 1bb26b68783..59ce07352a2 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -656,25 +656,16 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L656 end def converge_dependencies - frozen = Bundler.frozen_bundle? (@dependencies + locked_dependencies).each do |dep| - locked_source = @locked_deps[dep.name] - # This is to make sure that if bundler is installing in deployment mode and - # after locked_source and sources don't match, we still use locked_source. - if frozen && !locked_source.nil? && - locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist? - dep.source = locked_source.source - elsif dep.source + if dep.source dep.source = sources.get(dep.source) end end changes = false - # We want to know if all match, but don't want to check all entries - # This means we need to return false if any dependency doesn't match - # the lock or doesn't exist in the lock. - @dependencies.each do |dependency| - unless locked_dep = @locked_deps[dependency.name] + + @dependencies.each do |dep| + unless locked_dep = @locked_deps[dep.name] changes = true next end @@ -685,11 +676,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L676 # directive, the lockfile dependencies and resolved dependencies end up # with a mismatch on #type. Work around that by setting the type on the # dep from the lockfile. - locked_dep.instance_variable_set(:@type, dependency.type) + locked_dep.instance_variable_set(:@type, dep.type) # We already know the name matches from the hash lookup # so we only need to check the requirement now - changes ||= dependency.requirement != locked_dep.requirement + changes ||= dep.requirement != locked_dep.requirement end changes @@ -706,20 +697,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L697 # the gem in the Gemfile.lock still satisfies it, this is fine # too. @dependencies.each do |dep| - locked_dep = @locked_deps[dep.name] - - # If the locked_dep doesn't match the dependency we're looking for then we ignore the locked_dep - locked_dep = nil unless locked_dep == dep - - if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep) + if satisfies_locked_spec?(dep) deps << dep - elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source) - @locked_specs.each do |s| - @unlock[:gems] << s.name if s.source == dep.source - end - - dep.source.unlock! if dep.source.respond_to?(:unlock!) - dep.source.specs.each {|s| @unlock[:gems] << s.name } end end @@ -760,7 +739,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L739 s.dependencies.replace(new_spec.dependencies) end - converged << s + if dep.nil? && @dependencies.find {|d| s.name == d.name } + @unlock[:gems] << s.name + else + converged << s + end end resolve = SpecSet.new(converged) @@ -780,13 +763,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L763 resolve end - def in_locked_deps?(dep, locked_dep) - # Because the lockfile can't link a dep to a specific remote, we need to - # treat sources as equivalent anytime the locked dep has all the remotes - # that the Gemfile dep does. - locked_dep && locked_dep.source && dep.source && locked_dep.source.include?(dep.source) - end - def satisfies_locked_spec?(dep) @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) } end diff --git a/lib/rubygems/command.rb b/lib/rubygems/command.rb index 303f54a7d79..abdaa8e7c60 100644 --- a/lib/rubygems/command.rb +++ b/lib/rubygems/command.rb @@ -5,7 +5,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command.rb#L5 # See LICENSE.txt for permissions. #++ -require 'optparse' +require_relative 'optparse' require_relative 'requirement' require_relative 'user_interaction' @@ -19,7 +19,7 @@ require_relative 'user_interaction' https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command.rb#L19 class Gem::Command include Gem::UserInteraction - OptionParser.accept Symbol do |value| + Gem::OptionParser.accept Symbol do |value| value.to_sym end @@ -344,7 +344,7 @@ class Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command.rb#L344 ## # Add a command-line option and handler to the command. # - # See OptionParser#make_switch for an explanation of +opts+. + # See Gem::OptionParser#make_switch for an explanation of +opts+. # # +handler+ will be called with two values, the value of the argument and # the options hash. @@ -540,7 +540,7 @@ class Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command.rb#L540 # command. def create_option_parser - @parser = OptionParser.new + @parser = Gem::OptionParser.new add_parser_options diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb index 867cb07cca0..b59564d5759 100644 --- a/lib/rubygems/commands/cert_command.rb +++ b/lib/rubygems/commands/cert_command.rb @@ -51,7 +51,7 @@ class Gem::Commands::CertCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cert_command.rb#L51 add_option('-s', '--sign CERT', 'Signs CERT with the key from -K', 'and the certificate from -C') do |cert_file, options| - raise OptionParser::InvalidArgument, "#{cert_file}: does not exist" unless + raise Gem::OptionParser::InvalidArgument, "#{cert_file}: does not exist" unless File.file? cert_file options[:sign] << cert_file @@ -85,9 +85,9 @@ class Gem::Commands::CertCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cert_command.rb#L85 check_openssl OpenSSL::X509::Certificate.new File.read certificate_file rescue Errno::ENOENT - raise OptionParser::InvalidArgument, "#{certificate_file}: does not exist" + raise Gem::OptionParser::InvalidArgument, "#{certificate_file}: does not exist" rescue OpenSSL::X509::CertificateError - raise OptionParser::InvalidArgument, + raise Gem::OptionParser::InvalidArgument, "#{certificate_file}: invalid X509 certificate" end @@ -95,13 +95,13 @@ class Gem::Commands::CertCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cert_command.rb#L95 check_openssl passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE'] key = OpenSSL::PKey. (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/