ruby-changes:71179
From: Hiroshi <ko1@a...>
Date: Mon, 14 Feb 2022 13:57:07 +0900 (JST)
Subject: [ruby-changes:71179] c8b5d7031e (ruby_3_1): Merge RubyGems-3.3.7 and Bundler-2.3.7 (#5543)
https://git.ruby-lang.org/ruby.git/commit/?id=c8b5d7031e From c8b5d7031ebd6bbc0f51582d51a4b47ccd9b0138 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Mon, 14 Feb 2022 13:56:43 +0900 Subject: Merge RubyGems-3.3.7 and Bundler-2.3.7 (#5543) --- lib/bundler.rb | 2 +- lib/bundler/cli/config.rb | 11 +++++++- lib/bundler/cli/info.rb | 11 +++++++- lib/bundler/cli/install.rb | 31 +++++------------------ lib/bundler/fetcher.rb | 10 ++++---- lib/bundler/psyched_yaml.rb | 10 -------- lib/bundler/rubygems_ext.rb | 23 +++++++++-------- lib/bundler/rubygems_integration.rb | 16 ++---------- lib/bundler/settings.rb | 2 +- lib/bundler/version.rb | 2 +- lib/rubygems.rb | 2 +- lib/rubygems/specification.rb | 2 +- lib/rubygems/version.rb | 5 ++-- spec/bundler/bundler/fetcher_spec.rb | 4 +-- spec/bundler/bundler/rubygems_integration_spec.rb | 11 ++------ spec/bundler/commands/clean_spec.rb | 7 ++++- spec/bundler/commands/config_spec.rb | 14 +++++++++- spec/bundler/commands/exec_spec.rb | 6 ++--- spec/bundler/commands/info_spec.rb | 25 ++++++++++++++++++ spec/bundler/commands/inject_spec.rb | 2 +- spec/bundler/commands/lock_spec.rb | 9 +++++-- spec/bundler/install/gemfile/groups_spec.rb | 13 ++-------- spec/bundler/install/gems/standalone_spec.rb | 10 ++++++-- spec/bundler/realworld/parallel_spec.rb | 2 +- spec/bundler/spec_helper.rb | 2 +- spec/bundler/support/helpers.rb | 27 +++++++++++--------- spec/bundler/support/path.rb | 12 ++++++--- tool/bundler/dev_gems.rb.lock | 6 +++-- tool/bundler/rubocop_gems.rb.lock | 2 +- tool/bundler/standard_gems.rb.lock | 2 +- tool/bundler/test_gems.rb.lock | 2 +- 31 files changed, 154 insertions(+), 129 deletions(-) delete mode 100644 lib/bundler/psyched_yaml.rb diff --git a/lib/bundler.rb b/lib/bundler.rb index 89865a8254..8688206285 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -654,7 +654,7 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L654 private def eval_yaml_gemspec(path, contents) - require_relative "bundler/psyched_yaml" + Kernel.require "psych" Gem::Specification.from_yaml(contents) rescue ::Psych::SyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb index 8d2aba0916..e1222c75dd 100644 --- a/lib/bundler/cli/config.rb +++ b/lib/bundler/cli/config.rb @@ -180,7 +180,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/config.rb#L180 scopes = %w[global local].select {|s| options[s] } case scopes.size when 0 - @scope = "global" + @scope = inside_app? ? "local" : "global" @explicit_scope = false when 1 @scope = scopes.first @@ -189,6 +189,15 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/config.rb#L189 "The options #{scopes.join " and "} were specified. Please only use one of the switches at a time." end end + + private + + def inside_app? + Bundler.root + true + rescue GemfileNotFound + false + end end end end diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb index 76c8cf60c0..38bc008cb5 100644 --- a/lib/bundler/cli/info.rb +++ b/lib/bundler/cli/info.rb @@ -73,7 +73,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/info.rb#L73 gem_info << "\tBug Tracker: #{metadata["bug_tracker_uri"]}\n" if metadata.key?("bug_tracker_uri") gem_info << "\tMailing List: #{metadata["mailing_list_uri"]}\n" if metadata.key?("mailing_list_uri") gem_info << "\tPath: #{spec.full_gem_path}\n" - gem_info << "\tDefault Gem: yes" if spec.respond_to?(:default_gem?) && spec.default_gem? + gem_info << "\tDefault Gem: yes\n" if spec.respond_to?(:default_gem?) && spec.default_gem? + gem_info << "\tReverse Dependencies: \n\t\t#{gem_dependencies.join("\n\t\t")}" if gem_dependencies.any? if name != "bundler" && spec.deleted_gem? return Bundler.ui.warn "The gem #{name} has been deleted. Gemspec information is still available though:\n#{gem_info}" @@ -81,5 +82,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/info.rb#L82 Bundler.ui.info gem_info end + + def gem_dependencies + @gem_dependencies ||= Bundler.definition.specs.map do |spec| + dependency = spec.dependencies.find {|dep| dep.name == gem_name } + next unless dependency + "#{spec.name} (#{spec.version}) depends on #{gem_name} (#{dependency.requirements_list.join(", ")})" + end.compact.sort + end end end diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index c3400c3959..e9b85f7f6f 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -135,32 +135,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/install.rb#L135 end def normalize_groups - options[:with] &&= options[:with].join(":").tr(" ", ":").split(":") - options[:without] &&= options[:without].join(":").tr(" ", ":").split(":") - 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] - - without = options.fetch(:without, []) - without |= Bundler.settings[:without].map(&:to_s) - without -= options[:with] if options[: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 + # 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] + Bundler.settings.set_command_option :with, options[:with] end def normalize_settings @@ -184,7 +165,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/install.rb#L165 Bundler.settings.set_command_option_if_given :clean, options["clean"] - normalize_groups + normalize_groups if options[:without] || options[:with] options[:force] = options[:redownload] end diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 89103fe1ec..e07f925107 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -240,7 +240,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/fetcher.rb#L240 raise SSLError if needs_ssl && !defined?(OpenSSL::SSL) con = PersistentHTTP.new :name => "bundler", :proxy => :ENV - if gem_proxy = Bundler.rubygems.configuration[:http_proxy] + if gem_proxy = Gem.configuration[:http_proxy] con.proxy = Bundler::URI.parse(gem_proxy) if gem_proxy != :no_proxy end @@ -251,8 +251,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/fetcher.rb#L251 end ssl_client_cert = Bundler.settings[:ssl_client_cert] || - (Bundler.rubygems.configuration.ssl_client_cert if - Bundler.rubygems.configuration.respond_to?(:ssl_client_cert)) + (Gem.configuration.ssl_client_cert if + Gem.configuration.respond_to?(:ssl_client_cert)) if ssl_client_cert pem = File.read(ssl_client_cert) con.cert = OpenSSL::X509::Certificate.new(pem) @@ -283,8 +283,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/fetcher.rb#L283 def bundler_cert_store store = OpenSSL::X509::Store.new ssl_ca_cert = Bundler.settings[:ssl_ca_cert] || - (Bundler.rubygems.configuration.ssl_ca_cert if - Bundler.rubygems.configuration.respond_to?(:ssl_ca_cert)) + (Gem.configuration.ssl_ca_cert if + Gem.configuration.respond_to?(:ssl_ca_cert)) if ssl_ca_cert if File.directory? ssl_ca_cert store.add_path ssl_ca_cert diff --git a/lib/bundler/psyched_yaml.rb b/lib/bundler/psyched_yaml.rb deleted file mode 100644 index 3d9893031f..0000000000 --- a/lib/bundler/psyched_yaml.rb +++ /dev/null @@ -1,10 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/fetcher.rb#L0 -# frozen_string_literal: true - -begin - require "psych" -rescue LoadError - # Apparently Psych wasn't available. Oh well. -end - -# At least load the YAML stdlib, whatever that may be -require "yaml" unless defined?(YAML.dump) diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 5d572aa73d..cc06b9ee93 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -4,14 +4,12 @@ require "pathname" https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_ext.rb#L4 require "ruby (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/