ruby-changes:71859
From: Hiroshi <ko1@a...>
Date: Wed, 18 May 2022 10:03:14 +0900 (JST)
Subject: [ruby-changes:71859] c7bbed2994 (ruby_3_1): Merge RubyGems-3.3.13 and Bundler-2.3.13
https://git.ruby-lang.org/ruby.git/commit/?id=c7bbed2994 From c7bbed299493d0fe5323916b83dab04021bc570f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Tue, 17 May 2022 11:26:18 +0900 Subject: Merge RubyGems-3.3.13 and Bundler-2.3.13 --- lib/bundler/definition.rb | 30 +++++++++++--------- lib/bundler/endpoint_specification.rb | 5 +++- lib/bundler/version.rb | 2 +- lib/rubygems.rb | 4 +-- lib/rubygems/commands/owner_command.rb | 11 +++++-- spec/bundler/commands/install_spec.rb | 24 ++++++++++++++-- spec/bundler/commands/lock_spec.rb | 34 ++++++++++++++++++++++ spec/bundler/commands/update_spec.rb | 4 +++ spec/bundler/install/gemfile/platform_spec.rb | 2 +- spec/bundler/install/gemfile/sources_spec.rb | 41 +++++++++++++++++++++++++++ spec/bundler/install/gems/standalone_spec.rb | 2 +- test/rubygems/helper.rb | 16 +++++++---- test/rubygems/test_gem.rb | 20 ++++--------- tool/bundler/dev_gems.rb.lock | 2 +- tool/bundler/rubocop_gems.rb.lock | 3 +- tool/bundler/standard_gems.rb.lock | 3 +- tool/bundler/test_gems.rb.lock | 2 +- 17 files changed, 155 insertions(+), 50 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 21949bc85c..d862877c2e 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -87,10 +87,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L87 @platforms = @locked_platforms.dup @locked_bundler_version = @locked_gems.bundler_version @locked_ruby_version = @locked_gems.ruby_version + @originally_locked_specs = SpecSet.new(@locked_gems.specs) if unlock != true @locked_deps = @locked_gems.dependencies - @locked_specs = SpecSet.new(@locked_gems.specs) + @locked_specs = @originally_locked_specs @locked_sources = @locked_gems.sources else @unlock = {} @@ -255,14 +256,14 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L256 # @return [SpecSet] resolved dependencies def resolve @resolve ||= begin - last_resolve = converge_locked_specs if Bundler.frozen_bundle? Bundler.ui.debug "Frozen, using resolution from the lockfile" - last_resolve + @locked_specs elsif !unlocking? && nothing_changed? Bundler.ui.debug("Found no changes, using resolution from the lockfile") - last_resolve + SpecSet.new(filter_specs(@locked_specs, @dependencies.select{|dep| @locked_specs[dep].any? })) else + last_resolve = converge_locked_specs # Run a resolve against the locally available gems Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}") expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true) @@ -464,6 +465,10 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L465 private + def filter_specs(specs, deps) + SpecSet.new(specs).for(expand_dependencies(deps, true), false, false) + end + def materialize(dependencies) specs = resolve.materialize(dependencies) missing_specs = specs.missing_specs @@ -679,17 +684,17 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L684 end def converge_specs(specs) - deps = [] converged = [] + + deps = @dependencies.select do |dep| + specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) } + end + specs.each do |s| # Replace the locked dependency's source with the equivalent source from the Gemfile dep = @dependencies.find {|d| s.satisfies?(d) } - if dep && (!dep.source || s.source.include?(dep.source)) - deps << dep - end - - s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source unless Bundler.frozen_bundle? + s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source next if @unlock[:sources].include?(s.source.name) @@ -726,8 +731,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L731 end end - resolve = SpecSet.new(converged) - SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) }) + SpecSet.new(filter_specs(converged, deps).reject{|s| @unlock[:gems].include?(s.name) }) end def metadata_dependencies @@ -804,7 +808,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L808 def additional_base_requirements_for_resolve return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources) - converge_specs(@locked_gems.specs).map do |locked_spec| + converge_specs(@originally_locked_specs).map do |locked_spec| name = locked_spec.name dep = Gem::Dependency.new(name, ">= #{locked_spec.version}") DepProxy.get_proxy(dep, locked_spec.platform) diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb index f3260a38e6..e9aa366b41 100644 --- a/lib/bundler/endpoint_specification.rb +++ b/lib/bundler/endpoint_specification.rb @@ -26,8 +26,11 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/endpoint_specification.rb#L26 @required_ruby_version ||= _remote_specification.required_ruby_version end + # A fallback is included because the original version of the specification + # API didn't include that field, so some marshalled specs in the index have it + # set to +nil+. def required_rubygems_version - @required_rubygems_version ||= _remote_specification.required_rubygems_version + @required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default end def fetch_platform diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 8c645c7a49..aa9c29199d 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/version.rb#L1 # frozen_string_literal: false module Bundler - VERSION = "2.3.12".freeze + VERSION = "2.3.13".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 419b6e54b7..2cbb6a2410 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L8 require 'rbconfig' module Gem - VERSION = "3.3.12".freeze + VERSION = "3.3.13".freeze end # Must be first since it unloads the prelude from 1.9.2 @@ -864,7 +864,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} https://github.com/ruby/ruby/blob/trunk/lib/rubygems.rb#L864 return @ruby_version if defined? @ruby_version version = RUBY_VERSION.dup - if defined?(RUBY_DESCRIPTION) + unless defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1 if RUBY_ENGINE == "ruby" desc = RUBY_DESCRIPTION[/\Aruby #{Regexp.quote(RUBY_VERSION)}([^ ]+) /, 1] else diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb index 0a5665228f..42b0d79135 100644 --- a/lib/rubygems/commands/owner_command.rb +++ b/lib/rubygems/commands/owner_command.rb @@ -12,7 +12,12 @@ class Gem::Commands::OwnerCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/owner_command.rb#L12 def description # :nodoc: <<-EOF The owner command lets you add and remove owners of a gem on a push -server (the default is https://rubygems.org). +server (the default is https://rubygems.org). Multiple owners can be +added or removed at the same time, if the flag is given multiple times. + +The supported user identifiers are dependant on the push server. +For rubygems.org, both e-mail and handle are supported, even though the +user identifier field is called "email". The owner of a gem has the permission to push new versions, yank existing versions or edit the HTML page of the gem. Be careful of who you give push @@ -35,11 +40,11 @@ permission to. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/owner_command.rb#L40 add_otp_option defaults.merge! :add => [], :remove => [] - add_option '-a', '--add EMAIL', 'Add an owner' do |value, options| + add_option '-a', '--add NEW_OWNER', 'Add an owner by user identifier' do |value, options| options[:add] << value end - add_option '-r', '--remove EMAIL', 'Remove an owner' do |value, options| + add_option '-r', '--remove OLD_OWNER', 'Remove an owner by user identifier' do |value, options| options[:remove] << value end diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 610b8c189a..f189a70b10 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -364,7 +364,9 @@ RSpec.describe "bundle install with gem sources" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/install_spec.rb#L364 end it "throws a warning if a gem is added twice in Gemfile without version requirements" do - install_gemfile <<-G, :raise_on_error => false + build_repo2 + + install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "rack" gem "rack" @@ -376,7 +378,9 @@ RSpec.describe "bundle install with gem sources" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/install_spec.rb#L378 end it "throws a warning if a gem is added twice in (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/