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

ruby-changes:72736

From: Hiroshi <ko1@a...>
Date: Fri, 29 Jul 2022 15:46:29 +0900 (JST)
Subject: [ruby-changes:72736] bfd09b1116 (master): Merge rubygems master from https://github.com/rubygems/rubygems/commit/446cc57a7ccdf1924deb291be9571219e7ba8523

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

From bfd09b1116bcc747bab922b23c7322e4ec66c2c2 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 29 Jul 2022 14:59:56 +0900
Subject: Merge rubygems master from
 https://github.com/rubygems/rubygems/commit/446cc57a7ccdf1924deb291be9571219e7ba8523

---
 lib/bundler/cli.rb                          |  2 ++
 lib/bundler/definition.rb                   | 31 +++++++++++++++--
 lib/bundler/installer.rb                    |  9 ++++-
 lib/bundler/man/bundle-config.1             |  7 ++++
 lib/bundler/man/bundle-config.1.ronn        |  5 +++
 lib/bundler/man/bundle-inject.1             |  5 ++-
 lib/bundler/man/bundle-inject.1.ronn        |  4 ++-
 lib/bundler/man/bundle-install.1            |  4 +++
 lib/bundler/man/bundle-install.1.ronn       |  6 ++++
 lib/bundler/man/bundle.1                    |  5 ++-
 lib/bundler/man/bundle.1.ronn               |  3 +-
 lib/bundler/ruby_version.rb                 | 10 +++---
 lib/bundler/rubygems_ext.rb                 |  9 +++++
 lib/bundler/settings.rb                     |  1 +
 lib/bundler/source/metadata.rb              |  2 +-
 spec/bundler/bundler/ruby_version_spec.rb   | 10 +++---
 spec/bundler/commands/install_spec.rb       | 52 ++++++++++++++++++++++++++---
 spec/bundler/commands/lock_spec.rb          |  4 +--
 spec/bundler/commands/update_spec.rb        | 10 +++---
 spec/bundler/install/gemfile/ruby_spec.rb   | 14 ++++----
 spec/bundler/install/gems/resolving_spec.rb | 12 +++----
 spec/bundler/install/gemspecs_spec.rb       |  3 +-
 spec/bundler/lock/lockfile_spec.rb          |  4 +--
 spec/bundler/other/platform_spec.rb         | 16 ++++-----
 spec/bundler/support/helpers.rb             |  2 +-
 spec/bundler/support/platforms.rb           |  2 +-
 26 files changed, 174 insertions(+), 58 deletions(-)

diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index e1c284130b..e9ef47f9ba 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -218,6 +218,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli.rb#L218
       "Specify the number of jobs to run in parallel"
     method_option "local", :type => :boolean, :banner =>
       "Do not attempt to fetch gems remotely and use the gem cache instead"
+    method_option "prefer-local", :type => :boolean, :banner =>
+      "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
     method_option "no-cache", :type => :boolean, :banner =>
       "Don't update the existing gem cache."
     method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 4cb829470a..3e93b45171 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -70,6 +70,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L70
       @unlock          = unlock
       @optional_groups = optional_groups
       @remote          = false
+      @prefer_local    = false
       @specs           = nil
       @ruby_version    = ruby_version
       @gemfiles        = gemfiles
@@ -170,6 +171,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L171
       resolve
     end
 
+    def resolve_prefering_local!
+      @prefer_local = true
+      @remote = true
+      sources.remote!
+      resolve
+    end
+
     def resolve_with_cache!
       sources.cached!
       resolve
@@ -528,6 +536,19 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L536
       @remote && sources.non_global_rubygems_sources.all?(&:dependency_api_available?) && !sources.aggregate_global_source?
     end
 
+    def pin_locally_available_names(source_requirements)
+      source_requirements.each_with_object({}) do |(name, original_source), new_source_requirements|
+        local_source = original_source.dup
+        local_source.local_only!
+
+        new_source_requirements[name] = if local_source.specs.search(name).any?
+          local_source
+        else
+          original_source
+        end
+      end
+    end
+
     def current_ruby_platform_locked?
       return false unless generic_local_platform == Gem::Platform::RUBY
       return false if Bundler.settings[:force_ruby_platform] && !@platforms.include?(Gem::Platform::RUBY)
@@ -765,7 +786,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L786
 
     def metadata_dependencies
       @metadata_dependencies ||= [
-        Dependency.new("Ruby\0", RubyVersion.system.gem_version),
+        Dependency.new("Ruby\0", Gem.ruby_version),
         Dependency.new("RubyGems\0", Gem::VERSION),
       ]
     end
@@ -792,7 +813,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L813
       # specs will be available later when the resolver knows where to
       # look for that gemspec (or its dependencies)
       source_requirements = if precompute_source_requirements_for_indirect_dependencies?
-        { :default => sources.default_source }.merge(source_map.all_requirements)
+        all_requirements = source_map.all_requirements
+        all_requirements = pin_locally_available_names(all_requirements) if @prefer_local
+        { :default => sources.default_source }.merge(all_requirements)
       else
         { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
       end
@@ -806,7 +829,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L829
     end
 
     def requested_groups
-      groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
+      values = groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
+      values &= Bundler.settings[:only] unless Bundler.settings[:only].empty?
+      values
     end
 
     def lockfiles_equal?(current, proposed, preserve_unknown_sections)
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index f195d36600..b7b0e36dfd 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -268,7 +268,14 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/installer.rb#L268
         return false if @definition.nothing_changed? && !@definition.missing_specs?
       end
 
-      options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
+      if options["local"]
+        @definition.resolve_with_cache!
+      elsif options["prefer-local"]
+        @definition.resolve_prefering_local!
+      else
+        @definition.resolve_remotely!
+      end
+
       true
     end
 
diff --git a/lib/bundler/man/bundle-config.1 b/lib/bundler/man/bundle-config.1
index 76b444d8c6..b5cee57f29 100644
--- a/lib/bundler/man/bundle-config.1
+++ b/lib/bundler/man/bundle-config.1
@@ -74,6 +74,10 @@ Creates a directory (defaults to \fB~/bin\fR) and place any executables from the https://github.com/ruby/ruby/blob/trunk/lib/bundler/man/bundle-config.1#L74
 In deployment mode, Bundler will \'roll\-out\' the bundle for \fBproduction\fR use\. Please check carefully if you want to have this option enabled in \fBdevelopment\fR or \fBtest\fR environments\.
 .
 .TP
+\fBonly\fR
+A space\-separated list of groups to install only gems of the specified groups\.
+.
+.TP
 \fBpath\fR
 The location to install the specified gems to\. This defaults to Rubygems\' setting\. Bundler shares this location with Rubygems, \fBgem install \.\.\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \.\.\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
 .
@@ -223,6 +227,9 @@ The following is a list of all configuration keys and their purpose\. You can le https://github.com/ruby/ruby/blob/trunk/lib/bundler/man/bundle-config.1#L227
 \fBno_prune\fR (\fBBUNDLE_NO_PRUNE\fR): Whether Bundler should leave outdated gems unpruned when caching\.
 .
 .IP "\(bu" 4
+\fBonly\fR (\fBBUNDLE_ONLY\fR): A space\-separated list of groups to install only gems of the specified groups\.
+.
+.IP "\(bu" 4
 \fBpath\fR (\fBBUNDLE_PATH\fR): The location on disk where all gems in your bundle will be located regardless of \fB$GEM_HOME\fR or \fB$GEM_PATH\fR values\. Bundle gems not found in this location will be installed by \fBbundle install\fR\. Defaults to \fBGem\.dir\fR\. When \-\-deployment is used, defaults to vendor/bundle\.
 .
 .IP "\(bu" 4
diff --git a/lib/bundler/man/bundle-config.1.ronn b/lib/bundler/man/bundle-config.1.ronn
index 8a636641c0..e2af773141 100644
--- a/lib/bundler/man/bundle-config.1.ronn
+++ b/lib/bundler/man/bundle-config.1.ronn
@@ -74,6 +74,9 @@ The options that can be configured are: https://github.com/ruby/ruby/blob/trunk/lib/bundler/man/bundle-config.1.ronn#L74
    `production` use. Please check carefully if you want to have this option
    enabled in `development` or `test` environments.
 
+* `only`:
+   A space-separated list of groups to install only gems of the specified groups.
+
 * `path`:
    The location to install the specified gems to. This defaults to Rubygems'
    setting. Bundler shares this location with Rubygems, `gem install ...` will
@@ -218,6 +221,8 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html). https://github.com/ruby/ruby/blob/trunk/lib/bundler/man/bundle-config.1.ronn#L221
    Whether `bundle package` should skip installing gems.
 * `no_prune` (`BUNDLE_NO_PRUNE`):
    Whether Bundler should leave outdated gems unpruned when caching.
+* `only` (`BUNDLE_ONLY`):
+   A space-separated list of groups to install only gems of the specified groups.
 * `path` (`BUNDLE_PATH`):
    The location on disk where all gems in your bundle will be located regardless
    of `$GEM_HOME` or `$GEM_PATH` values. Bundle gems not found in this location
diff --git a/lib/bundler/man/bundle-inject.1 b/lib/bundler/man/bundle-inject.1
index 0f6627d9a3..53f2eaae0a 100644
 (... truncated)

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

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