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

ruby-changes:70442

From: Hiroshi <ko1@a...>
Date: Thu, 23 Dec 2021 09:44:56 +0900 (JST)
Subject: [ruby-changes:70442] fb1ab27f53 (master): Merge RubyGems-3.3.1 and Bundler-2.3.1

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

From fb1ab27f535833f1ba1648d7cdce4cc893e36d07 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Thu, 23 Dec 2021 09:21:36 +0900
Subject: Merge RubyGems-3.3.1 and Bundler-2.3.1

---
 lib/bundler/rubygems_gem_installer.rb              |  2 +-
 lib/bundler/self_manager.rb                        |  5 +-
 lib/bundler/vendor/thor/lib/thor/actions.rb        |  8 ++-
 .../thor/lib/thor/actions/file_manipulation.rb     | 12 ++--
 .../thor/lib/thor/actions/inject_into_file.rb      |  8 ++-
 .../thor/core_ext/hash_with_indifferent_access.rb  |  6 ++
 lib/bundler/vendor/thor/lib/thor/error.rb          | 13 +++--
 lib/bundler/vendor/thor/lib/thor/parser/options.rb | 20 ++++++-
 lib/bundler/vendor/thor/lib/thor/shell.rb          |  2 +-
 lib/bundler/vendor/thor/lib/thor/shell/basic.rb    | 26 +++++++--
 lib/bundler/vendor/thor/lib/thor/util.rb           |  2 +-
 lib/bundler/version.rb                             |  2 +-
 lib/rubygems.rb                                    |  5 +-
 lib/rubygems/bundler_version_finder.rb             | 52 ++++-------------
 lib/rubygems/dependency.rb                         | 14 ++---
 lib/rubygems/errors.rb                             |  3 -
 lib/rubygems/security.rb                           | 14 +++--
 lib/rubygems/security/policy.rb                    |  4 +-
 lib/rubygems/specification.rb                      |  2 -
 spec/bundler/install/gems/standalone_spec.rb       |  2 +-
 spec/bundler/realworld/mirror_probe_spec.rb        | 33 ++++-------
 spec/bundler/runtime/gem_tasks_spec.rb             |  6 +-
 spec/bundler/support/artifice/compact_index.rb     |  2 +-
 spec/bundler/support/artifice/endpoint.rb          |  2 +-
 spec/bundler/support/artifice/endpoint_500.rb      |  2 +-
 spec/bundler/support/artifice/windows.rb           |  2 +-
 spec/bundler/support/builders.rb                   |  2 +-
 spec/bundler/support/helpers.rb                    |  2 +-
 spec/bundler/support/path.rb                       |  4 ++
 spec/bundler/support/rubygems_ext.rb               |  9 +--
 test/rubygems/test_gem.rb                          | 35 ------------
 test/rubygems/test_gem_bundler_version_finder.rb   | 65 ++++++++--------------
 test/rubygems/test_gem_dependency.rb               | 12 ++--
 test/rubygems/test_kernel.rb                       | 14 +----
 test/rubygems/test_require.rb                      | 25 ---------
 tool/bundler/rubocop_gems.rb.lock                  |  2 +-
 tool/bundler/standard_gems.rb.lock                 |  2 +-
 tool/bundler/test_gems.rb.lock                     |  2 +-
 38 files changed, 170 insertions(+), 253 deletions(-)

diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb
index bb9f1cb3f5c..452583617b3 100644
--- a/lib/bundler/rubygems_gem_installer.rb
+++ b/lib/bundler/rubygems_gem_installer.rb
@@ -67,7 +67,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_gem_installer.rb#L67
     def build_extensions
       extension_cache_path = options[:bundler_extension_cache_path]
       unless extension_cache_path && extension_dir = spec.extension_dir
-        require "shellwords" # compensate missing require in rubygems before version 3.2.25
+        require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
         return super
       end
 
diff --git a/lib/bundler/self_manager.rb b/lib/bundler/self_manager.rb
index bda2eb51f34..d62ef6ca12e 100644
--- a/lib/bundler/self_manager.rb
+++ b/lib/bundler/self_manager.rb
@@ -39,10 +39,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/self_manager.rb#L39
       configured_gem_home = ENV["GEM_HOME"]
       configured_gem_path = ENV["GEM_PATH"]
 
+      cmd = [$PROGRAM_NAME, *ARGV]
+      cmd.unshift(Gem.ruby) unless File.executable?($PROGRAM_NAME)
+
       Bundler.with_original_env do
         Kernel.exec(
           { "GEM_HOME" => configured_gem_home, "GEM_PATH" => configured_gem_path, "BUNDLER_VERSION" => lockfile_version },
-          $PROGRAM_NAME, *ARGV
+          *cmd
         )
       end
     end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions.rb b/lib/bundler/vendor/thor/lib/thor/actions.rb
index de9323b2dbe..de9b3b4c86f 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions.rb
@@ -161,6 +161,8 @@ class Bundler::Thor https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/thor/lib/thor/actions.rb#L161
     # to the block you provide. The path is set back to the previous path when
     # the method exits.
     #
+    # Returns the value yielded by the block.
+    #
     # ==== Parameters
     # dir<String>:: the directory to move to.
     # config<Hash>:: give :verbose => true to log and use padding.
@@ -179,16 +181,18 @@ class Bundler::Thor https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/thor/lib/thor/actions.rb#L181
         FileUtils.mkdir_p(destination_root)
       end
 
+      result = nil
       if pretend
         # In pretend mode, just yield down to the block
-        block.arity == 1 ? yield(destination_root) : yield
+        result = block.arity == 1 ? yield(destination_root) : yield
       else
         require "fileutils"
-        FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
+        FileUtils.cd(destination_root) { result = block.arity == 1 ? yield(destination_root) : yield }
       end
 
       @destination_stack.pop
       shell.padding -= 1 if verbose
+      result
     end
 
     # Goes to the root and execute the given block.
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
index 90a8d2e8472..bf2a737c849 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
@@ -210,9 +210,9 @@ class Bundler::Thor https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb#L210
     #
     # ==== Examples
     #
-    #   inject_into_class "app/controllers/application_controller.rb", ApplicationController, "  filter_parameter :password\n"
+    #   inject_into_class "app/controllers/application_controller.rb", "ApplicationController", "  filter_parameter :password\n"
     #
-    #   inject_into_class "app/controllers/application_controller.rb", ApplicationController do
+    #   inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
     #     "  filter_parameter :password\n"
     #   end
     #
@@ -233,9 +233,9 @@ class Bundler::Thor https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb#L233
     #
     # ==== Examples
     #
-    #   inject_into_module "app/helpers/application_helper.rb", ApplicationHelper, "  def help; 'help'; end\n"
+    #   inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper", "  def help; 'help'; end\n"
     #
-    #   inject_into_module "app/helpers/application_helper.rb", ApplicationHelper do
+    #   inject_into_module "app/helpers/application_helper.rb", "ApplicationHelper" do
     #     "  def help; 'help'; end\n"
     #   end
     #
@@ -252,7 +252,7 @@ class Bundler::Thor https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb#L252
     # flag<Regexp|String>:: the regexp or string to be replaced
     # replacement<String>:: the replacement, can be also given as a block
     # config<Hash>:: give :verbose => false to not log the status, and
-    #                :force => true, to force the replacement regardless of runner behavior.
+    #                :force => true, to force the replacement regardles of runner behavior.
     #
     # ==== Example
     #
@@ -331,7 +331,7 @@ class Bundler::Thor https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb#L331
       path = File.expand_path(path, destination_root)
 
       say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)
-      if !options[:pretend] && File.exist?(path)
+      if !options[:pretend] && (File.exist?(path) || File.symlink?(path))
         require "fileutils"
         ::FileUtils.rm_rf(path)
       end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
index 09ce0864f01..f52ced2bcd9 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
@@ -106,12 +106,14 @@ class Bundler::Thor https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb#L106
       # Adds the content to the file.
       #
       def replace!(regexp, string, force)
-        return if pretend?
         content = File.read(destination)
-        if force || !content.include?(replacement)
+        before, after = content.split(regexp, 2)
+        snippet = (behavior == :after ? after : before).to_s
+
+        if force || !snippet.include?(replacement)
           success = content.gsub!(regexp, string)
 
-          File.open(destination, "wb") { |file| file.write(content) }
+          File.open(destination, "wb") { |file| file.write(content) } unless pretend?
           success
         end
       end
diff --git a/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
index c167aa33b86..3c4483e5dda 100644
--- a/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
+++ b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
@@ -28,6 +28,12 @@ class Bundler::Thor https://github.com/ruby/ruby/blob/trunk/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb#L28
         super(convert_key(key))
       end
 
+      def except(*keys)
+      (... truncated)

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

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