ruby-changes:70977
From: Hiroshi <ko1@a...>
Date: Wed, 19 Jan 2022 15:01:58 +0900 (JST)
Subject: [ruby-changes:70977] d22511fd75 (master): Merge rubygems/rubygems HEAD.
https://git.ruby-lang.org/ruby.git/commit/?id=d22511fd75 From d22511fd7595ef1819baa42851d598d95b8f4d00 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Wed, 19 Jan 2022 13:28:23 +0900 Subject: Merge rubygems/rubygems HEAD. Picked at 12aeef6ba9a3be0022be9934c1a3e4c46a03ed3a --- lib/bundler/cli.rb | 13 +- lib/bundler/cli/update.rb | 8 +- lib/bundler/compact_index_client.rb | 6 - lib/bundler/compact_index_client/cache.rb | 9 -- lib/bundler/definition.rb | 8 - lib/bundler/endpoint_specification.rb | 24 ++- lib/bundler/fetcher.rb | 13 +- lib/bundler/fetcher/compact_index.rb | 10 -- lib/bundler/fetcher/index.rb | 26 ---- lib/bundler/lazy_specification.rb | 4 +- lib/bundler/lockfile_generator.rb | 2 +- lib/bundler/resolver.rb | 10 +- lib/bundler/resolver/spec_group.rb | 2 +- lib/bundler/self_manager.rb | 132 ++++++++++++---- .../thor/lib/thor/actions/inject_into_file.rb | 5 +- lib/bundler/vendor/thor/lib/thor/version.rb | 2 +- lib/rubygems.rb | 13 +- lib/rubygems/package.rb | 2 +- lib/rubygems/package/old.rb | 2 +- lib/rubygems/psych_additions.rb | 2 +- lib/rubygems/safe_yaml.rb | 16 +- lib/rubygems/security.rb | 2 +- lib/rubygems/specification.rb | 4 +- spec/bundler/bundler/cli_spec.rb | 4 +- .../bundler/bundler/endpoint_specification_spec.rb | 7 +- spec/bundler/commands/binstubs_spec.rb | 8 +- spec/bundler/commands/update_spec.rb | 170 ++++++++++++++++++++- spec/bundler/install/gemfile/gemspec_spec.rb | 2 +- spec/bundler/install/gems/dependency_api_spec.rb | 11 -- spec/bundler/install/gems/resolving_spec.rb | 35 ++++- .../support/artifice/endpoint_api_missing.rb | 18 --- test/rubygems/helper.rb | 12 +- test/rubygems/test_gem_package.rb | 4 +- tool/bundler/rubocop_gems.rb.lock | 20 +-- tool/bundler/standard_gems.rb.lock | 28 ++-- 35 files changed, 400 insertions(+), 234 deletions(-) delete mode 100644 spec/bundler/support/artifice/endpoint_api_missing.rb diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index f6e20e7c675..16651dfad94 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -809,17 +809,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L809 current = Gem::Version.new(VERSION) return if current >= latest - latest_installed = Bundler.rubygems.find_name("bundler").map(&:version).max - installation = "To install the latest version, run `gem install bundler#{" --pre" if latest.prerelease?}`" - if latest_installed && latest_installed > current - suggestion = "To update to the most recent installed version (#{latest_installed}), run `bundle update --bundler`" - suggestion = "#{installation}\n#{suggestion}" if latest_installed < latest - else - suggestion = installation - end - - Bundler.ui.warn "The latest bundler is #{latest}, but you are currently running #{current}.\n#{suggestion}" + Bundler.ui.warn \ + "The latest bundler is #{latest}, but you are currently running #{current}.\n" \ + "To update to the most recent version, run `bundle update --bundler`" rescue RuntimeError nil end diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 95a8886ea5c..b49182655bf 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -11,12 +11,16 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/update.rb#L11 def run Bundler.ui.level = "warn" if options[:quiet] + update_bundler = options[:bundler] + + Bundler.self_manager.update_bundler_and_restart_with_it_if_needed(update_bundler) if update_bundler + Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins? sources = Array(options[:source]) groups = Array(options[:group]).map(&:to_sym) - full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !options[:bundler] + full_update = gems.empty? && sources.empty? && groups.empty? && !options[:ruby] && !update_bundler if full_update && !options[:all] if Bundler.feature_flag.update_requires_all_flag? @@ -49,7 +53,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/update.rb#L53 Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby], :conservative => conservative, - :bundler => options[:bundler]) + :bundler => update_bundler) end Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb index d5dbeb3b108..127a50e8108 100644 --- a/lib/bundler/compact_index_client.rb +++ b/lib/bundler/compact_index_client.rb @@ -73,12 +73,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/compact_index_client.rb#L73 end.flatten(1) end - def spec(name, version, platform = nil) - Bundler::CompactIndexClient.debug { "spec(name = #{name}, version = #{version}, platform = #{platform})" } - update_info(name) - @cache.specific_dependency(name, version, platform) - end - def update_and_parse_checksums! Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" } return @info_checksums_by_name if @parsed_checksums diff --git a/lib/bundler/compact_index_client/cache.rb b/lib/bundler/compact_index_client/cache.rb index c2cd069ec13..2d83777139b 100644 --- a/lib/bundler/compact_index_client/cache.rb +++ b/lib/bundler/compact_index_client/cache.rb @@ -76,15 +76,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/compact_index_client/cache.rb#L76 end end - def specific_dependency(name, version, platform) - pattern = [version, platform].compact.join("-") - return nil if pattern.empty? - - gem_lines = info_path(name).read - gem_line = gem_lines[/^#{Regexp.escape(pattern)}\b.*/, 0] - gem_line ? parse_gem(gem_line) : nil - end - private def lines(path) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index f985e6a3742..c31c41f76d4 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -310,14 +310,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L310 end end - def locked_bundler_version - if @locked_bundler_version && @locked_bundler_version < Gem::Version.new(Bundler::VERSION) - new_version = Bundler::VERSION - end - - new_version || @locked_bundler_version || Bundler::VERSION - end - def locked_ruby_version return unless ruby_version if @unlock[:ruby] || !@locked_ruby_version diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb index 6cf597b943d..f3260a38e6a 100644 --- a/lib/bundler/endpoint_specification.rb +++ b/lib/bundler/endpoint_specification.rb @@ -5,14 +5,15 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/endpoint_specification.rb#L5 class EndpointSpecification < Gem::Specification include MatchPlatform - attr_reader :name, :version, :platform, :required_rubygems_version, :required_ruby_version, :checksum + attr_reader :name, :version, :platform, :checksum attr_accessor :source, :remote, :dependencies - def initialize(name, version, platform, dependencies, metadata = nil) + def initialize(name, version, platform, spec_fetcher, dependencies, metadata = nil) super() @name = name @version = Gem::Version.create version @platform = platform + @spec_fetcher = spec_fetcher @dependencies = dependencies.map {|dep, reqs| build_dependency(dep, reqs) } @loaded_from = nil @@ -21,6 +22,14 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/endpoint_specification.rb#L22 parse_metadata(metadata) end + def required_ruby_version + @required_ruby_version ||= _remote_specification.required_ruby_version + end + + def required_rubygems_version + @required_rubygems_version ||= _remote_specification.required_rubygems_version + end + def fetch_platform @platform end @@ -105,12 +114,21 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/endpoint_specification.rb#L114 private + def _remote_specification + @_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @platform]) + end + def local_specification_path "#{base_dir}/specifications/#{full_name}.gemspec" end def parse_metadata(data) - return unless data + unless data + @required_ruby_version = nil + @required_rubygems_version = nil + return + end + data.each do |k, v| next unless v case k.to_s diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index a453157e686..89103fe1ec7 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -129,17 +129,15 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/fetcher.rb#L129 specs = fetchers.last.specs(gem_names) else specs = [] - fetchers.shift until fetchers.first.available? || fetchers.empty? - fe (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/