[前][次][番号順一覧][スレッド一覧]

ruby-changes:72525

From: Hiroshi <ko1@a...>
Date: Wed, 13 Jul 2022 14:12:17 +0900 (JST)
Subject: [ruby-changes:72525] 437a5ae9d6 (master): Merge RubyGems and Bundler master

https://git.ruby-lang.org/ruby.git/commit/?id=437a5ae9d6

From 437a5ae9d6d60bd1972641167a98204007bd1c0b Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Wed, 13 Jul 2022 12:56:36 +0900
Subject: Merge RubyGems and Bundler master

---
 lib/bundler.rb                                     |   2 +-
 lib/bundler/current_ruby.rb                        |   2 +-
 lib/bundler/definition.rb                          |  26 +++-
 lib/bundler/dependency.rb                          |   8 +-
 lib/bundler/dsl.rb                                 |   2 +-
 lib/bundler/force_platform.rb                      |  18 +++
 lib/bundler/gem_helpers.rb                         |   2 +
 lib/bundler/index.rb                               |   6 +-
 lib/bundler/lazy_specification.rb                  |  14 +-
 lib/bundler/lockfile_parser.rb                     |   4 +
 lib/bundler/man/gemfile.5                          |  26 +++-
 lib/bundler/man/gemfile.5.ronn                     |  18 ++-
 lib/bundler/match_platform.rb                      |   1 -
 lib/bundler/resolver.rb                            |   9 +-
 lib/bundler/resolver/spec_group.rb                 |   9 +-
 lib/bundler/rubygems_ext.rb                        |  35 ++---
 lib/bundler/spec_set.rb                            |  13 +-
 lib/rubygems/gem_runner.rb                         |  10 +-
 lib/rubygems/installer.rb                          |   2 +-
 lib/rubygems/platform.rb                           |   4 +
 lib/rubygems/specification.rb                      |  15 +++
 spec/bundler/bundler/definition_spec.rb            |   2 +-
 spec/bundler/commands/lock_spec.rb                 |  10 +-
 spec/bundler/commands/outdated_spec.rb             |   2 +-
 .../install/gemfile/force_ruby_platform_spec.rb    | 118 ++++++++++++++++
 spec/bundler/install/gemfile/gemspec_spec.rb       | 149 +++++++++++----------
 spec/bundler/install/gemfile/git_spec.rb           |   4 +-
 spec/bundler/install/gemfile/platform_spec.rb      |  20 +--
 .../install/gemfile/specific_platform_spec.rb      |  51 ++++---
 spec/bundler/install/gemfile_spec.rb               |   2 +-
 spec/bundler/install/gems/resolving_spec.rb        |   6 +-
 spec/bundler/lock/lockfile_spec.rb                 |   2 +-
 spec/bundler/other/ext_spec.rb                     |   4 +
 spec/bundler/other/platform_spec.rb                |  58 ++++----
 spec/bundler/resolver/platform_spec.rb             |  20 ++-
 spec/bundler/runtime/platform_spec.rb              |  68 +++++++++-
 spec/bundler/runtime/require_spec.rb               |   2 -
 spec/bundler/runtime/setup_spec.rb                 |  16 +++
 spec/bundler/support/builders.rb                   |   4 +
 spec/bundler/support/filters.rb                    |   4 +-
 spec/bundler/support/platforms.rb                  |  12 +-
 spec/bundler/support/rubygems_ext.rb               |   4 +-
 .../rubygems/test_gem_commands_pristine_command.rb |   1 +
 test/rubygems/test_gem_platform.rb                 |  16 +++
 test/rubygems/test_gem_specification.rb            |   2 +
 tool/bundler/dev_gems.rb.lock                      |   2 +
 tool/bundler/rubocop_gems.rb.lock                  |   2 +
 tool/bundler/standard_gems.rb.lock                 |   2 +
 tool/bundler/test_gems.rb.lock                     |   2 +
 49 files changed, 578 insertions(+), 233 deletions(-)
 create mode 100644 lib/bundler/force_platform.rb
 create mode 100644 spec/bundler/install/gemfile/force_ruby_platform_spec.rb

diff --git a/lib/bundler.rb b/lib/bundler.rb
index c99114ae64..9fb9ce3e82 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -455,7 +455,7 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/bundler.rb#L455
     end
 
     def local_platform
-      return Gem::Platform::RUBY if settings[:force_ruby_platform] || Gem.platforms == [Gem::Platform::RUBY]
+      return Gem::Platform::RUBY if settings[:force_ruby_platform]
       Gem::Platform.local
     end
 
diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb
index 27997982c0..36f26b7ab4 100644
--- a/lib/bundler/current_ruby.rb
+++ b/lib/bundler/current_ruby.rb
@@ -78,7 +78,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/current_ruby.rb#L78
     end
 
     def x64_mingw?
-      Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
+      Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os.start_with?("mingw") && Bundler.local_platform.cpu == "x64"
     end
 
     (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 2e0f23a402..0580860845 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -235,6 +235,14 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L235
       @locked_deps.values
     end
 
+    def new_deps
+      @new_deps ||= @dependencies - locked_dependencies
+    end
+
+    def deleted_deps
+      @deleted_deps ||= locked_dependencies - @dependencies
+    end
+
     def specs_for(groups)
       return specs if groups.empty?
       deps = dependencies_for(groups)
@@ -259,8 +267,17 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L267
         Bundler.ui.debug "Frozen, using resolution from the lockfile"
         @locked_specs
       elsif !unlocking? && nothing_changed?
-        Bundler.ui.debug("Found no changes, using resolution from the lockfile")
-        SpecSet.new(filter_specs(@locked_specs, @dependencies.select {|dep| @locked_specs[dep].any? }))
+        if deleted_deps.any?
+          Bundler.ui.debug("Some dependencies were deleted, using a subset of the resolution from the lockfile")
+          SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
+        else
+          Bundler.ui.debug("Found no changes, using resolution from the lockfile")
+          if @locked_gems.may_include_redundant_platform_specific_gems?
+            SpecSet.new(filter_specs(@locked_specs, @dependencies))
+          else
+            @locked_specs
+          end
+        end
       else
         last_resolve = converge_locked_specs
         # Run a resolve against the locally available gems
@@ -359,9 +376,6 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L376
       added.concat new_platforms.map {|p| "* platform: #{p}" }
       deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }
 
-      new_deps = @dependencies - locked_dependencies
-      deleted_deps = locked_dependencies - @dependencies
-
       added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
       deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
 
@@ -806,7 +820,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L820
       return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
       converge_specs(@originally_locked_specs).map do |locked_spec|
         name = locked_spec.name
-        dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
+        dep = Dependency.new(name, ">= #{locked_spec.version}")
         DepProxy.get_proxy(dep, locked_spec.platform)
       end
     end
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 018a3182b9..2449cb6411 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -1,13 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L1
 # frozen_string_literal: true
 
 require "rubygems/dependency"
+require_relative "force_platform"
 require_relative "shared_helpers"
 require_relative "rubygems_ext"
 
 module Bundler
   class Dependency < Gem::Dependency
+    include ForcePlatform
+
     attr_reader :autorequire
-    attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref
+    attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref, :force_ruby_platform
 
     # rubocop:disable Naming/VariableNumber
     PLATFORM_MAP = {
@@ -109,6 +112,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L112
       @env            = options["env"]
       @should_include = options.fetch("should_include", true)
       @gemfile        = options["gemfile"]
+      @force_ruby_platform = options.fetch("force_ruby_platform", default_force_ruby_platform)
 
       @autorequire = Array(options["require"] || []) if options.key?("require")
     end
@@ -122,7 +126,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L126
     end
 
     def expanded_platforms
-      @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq
+      @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq
     end
 
     def should_include?
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index bfa078046c..8b2d0ac97c 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -16,7 +16,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dsl.rb#L16
     VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
 
     VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
-                    platform platforms type source install_if gemfile].freeze
+                    platform platforms type source install_if gemfile force_ruby_platform].freeze
 
     GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}.freeze
 
diff --git a/lib/bundler/force_platform.rb b/lib/bundler/force_platform.rb
new file mode 100644
index 0000000000..0648ea9737
--- /dev/null
+++ b/lib/bundler/force_platform.rb
@@ -0,0 +1,18 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/force_platform.rb#L1
+# frozen_string_literal: true
+
+module Bundler
+  module ForcePlatform
+    private
+
+    # The `:force_ruby_platform` value used by dependencie (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]