summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2022-02-14 13:56:43 +0900
committerGitHub <noreply@github.com>2022-02-14 13:56:43 +0900
commitc8b5d7031ebd6bbc0f51582d51a4b47ccd9b0138 (patch)
tree19e17d093a3652614750c538c2ddfeef90ff98b4 /lib
parent36fa57fca0d5ecb317de8dba616a2225f3cac27a (diff)
Merge RubyGems-3.3.7 and Bundler-2.3.7 (#5543)
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler.rb2
-rw-r--r--lib/bundler/cli/config.rb11
-rw-r--r--lib/bundler/cli/info.rb11
-rw-r--r--lib/bundler/cli/install.rb31
-rw-r--r--lib/bundler/fetcher.rb10
-rw-r--r--lib/bundler/psyched_yaml.rb10
-rw-r--r--lib/bundler/rubygems_ext.rb23
-rw-r--r--lib/bundler/rubygems_integration.rb16
-rw-r--r--lib/bundler/settings.rb2
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/specification.rb2
-rw-r--r--lib/rubygems/version.rb5
13 files changed, 54 insertions, 73 deletions
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
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
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
"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
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
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
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
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
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
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
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 @@
-# 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"
require "rubygems/specification"
-# Possible use in Gem::Specification#source below and require
-# shouldn't be deferred.
-require "rubygems/source"
-
require_relative "match_platform"
module Gem
class Specification
+ include ::Bundler::MatchPlatform
+
attr_accessor :remote, :location, :relative_loaded_from
remove_method :source
@@ -81,6 +79,17 @@ module Gem
gemfile
end
+ # Backfill missing YAML require when not defined. Fixed since 3.1.0.pre1.
+ module YamlBackfiller
+ def to_yaml(opts = {})
+ Gem.load_yaml unless defined?(::YAML)
+
+ super(opts)
+ end
+ end
+
+ prepend YamlBackfiller
+
def nondevelopment_dependencies
dependencies - development_dependencies
end
@@ -228,9 +237,3 @@ module Gem
end
end
end
-
-module Gem
- class Specification
- include ::Bundler::MatchPlatform
- end
-end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 785f7fa360..1c2b374d8b 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -104,18 +104,6 @@ module Bundler
obj.to_s
end
- def configuration
- require_relative "psyched_yaml"
- Gem.configuration
- rescue Gem::SystemExitException, LoadError => e
- Bundler.ui.error "#{e.class}: #{e.message}"
- Bundler.ui.trace e
- raise
- rescue ::Psych::SyntaxError => e
- raise YamlSyntaxError.new(e, "Your RubyGems configuration, which is " \
- "usually located in ~/.gemrc, contains invalid YAML syntax.")
- end
-
def ruby_engine
Gem.ruby_engine
end
@@ -217,7 +205,7 @@ module Bundler
def spec_from_gem(path, policy = nil)
require "rubygems/security"
- require_relative "psyched_yaml"
+ require "psych"
gem_from_path(path, security_policies[policy]).spec
rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
if e.is_a?(Gem::Security::Exception) ||
@@ -522,7 +510,7 @@ module Bundler
def gem_remote_fetcher
require "rubygems/remote_fetcher"
- proxy = configuration[:http_proxy]
+ proxy = Gem.configuration[:http_proxy]
Gem::RemoteFetcher.new(proxy)
end
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index 72728fb20f..8f263cd012 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -367,7 +367,7 @@ module Bundler
def to_array(value)
return [] unless value
- value.split(":").map(&:to_sym)
+ value.tr(" ", ":").split(":").map(&:to_sym)
end
def array_to_s(array)
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 99bceb5afd..72c079b353 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.3.6".freeze
+ VERSION = "2.3.7".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index e96a418f9f..ee22e5405a 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
- VERSION = "3.3.6".freeze
+ VERSION = "3.3.7".freeze
end
# Must be first since it unloads the prelude from 1.9.2
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 43ab917d19..0d72cee51d 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-# -*- coding: utf-8 -*-
+#
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb
index d8aeb6f278..c59501ad5d 100644
--- a/lib/rubygems/version.rb
+++ b/lib/rubygems/version.rb
@@ -1,4 +1,7 @@
# frozen_string_literal: true
+
+require_relative "deprecate"
+
##
# The Version class processes string versions into comparable
# values. A version string should normally be a series of numbers
@@ -149,8 +152,6 @@
# For the last example, single-digit versions are automatically extended with
# a zero to give a sensible result.
-require_relative "deprecate"
-
class Gem::Version
autoload :Requirement, File.expand_path('requirement', __dir__)