From 8759d6c3627f9568d63e917e19c4446f33d61f61 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 19 Jul 2023 14:15:15 +0900 Subject: [PATCH] Merge RubyGems-3.4.17 and Bundler-2.4.17 --- lib/bundler/feature_flag.rb | 1 - lib/bundler/man/bundle-config.1 | 3 -- lib/bundler/man/bundle-config.1.ronn | 3 -- lib/bundler/settings.rb | 1 - lib/bundler/source.rb | 2 +- lib/bundler/source/git.rb | 32 ++++++++----- lib/bundler/version.rb | 2 +- lib/rubygems.rb | 2 +- lib/rubygems/resolver/installer_set.rb | 4 +- spec/bundler/commands/update_spec.rb | 48 +++++++++---------- spec/bundler/install/gemfile/git_spec.rb | 7 +++ spec/bundler/install/git_spec.rb | 2 - .../rubygems/test_gem_dependency_installer.rb | 34 +++++++++++++ test/rubygems/test_gem_request.rb | 13 +++-- 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 +- 18 files changed, 101 insertions(+), 61 deletions(-) diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 983de3137c6a1d..ab2189f7f05ed2 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -37,7 +37,6 @@ def self.settings_method(name, key, &default) settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") } settings_flag(:print_only_version_number) { bundler_3_mode? } settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? } - settings_flag(:suppress_install_using_messages) { bundler_3_mode? } settings_flag(:update_requires_all_flag) { bundler_4_mode? } settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install } diff --git a/lib/bundler/man/bundle-config.1 b/lib/bundler/man/bundle-config.1 index 0e7046a4a266c5..82e5257253d98d 100644 --- a/lib/bundler/man/bundle-config.1 +++ b/lib/bundler/man/bundle-config.1 @@ -284,9 +284,6 @@ The following is a list of all configuration keys and their purpose\. You can le \fBssl_verify_mode\fR (\fBBUNDLE_SSL_VERIFY_MODE\fR): The SSL verification mode Bundler uses when making HTTPS requests\. Defaults to verify peer\. . .IP "\(bu" 4 -\fBsuppress_install_using_messages\fR (\fBBUNDLE_SUPPRESS_INSTALL_USING_MESSAGES\fR): Avoid printing \fBUsing \.\.\.\fR messages during installation when the version of a gem has not changed\. -. -.IP "\(bu" 4 \fBsystem_bindir\fR (\fBBUNDLE_SYSTEM_BINDIR\fR): The location where RubyGems installs binstubs\. Defaults to \fBGem\.bindir\fR\. . .IP "\(bu" 4 diff --git a/lib/bundler/man/bundle-config.1.ronn b/lib/bundler/man/bundle-config.1.ronn index bc8b27cf89cdbd..adc273ec622623 100644 --- a/lib/bundler/man/bundle-config.1.ronn +++ b/lib/bundler/man/bundle-config.1.ronn @@ -265,9 +265,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html). * `ssl_verify_mode` (`BUNDLE_SSL_VERIFY_MODE`): The SSL verification mode Bundler uses when making HTTPS requests. Defaults to verify peer. -* `suppress_install_using_messages` (`BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES`): - Avoid printing `Using ...` messages during installation when the version of - a gem has not changed. * `system_bindir` (`BUNDLE_SYSTEM_BINDIR`): The location where RubyGems installs binstubs. Defaults to `Gem.bindir`. * `timeout` (`BUNDLE_TIMEOUT`): diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 85d7917eedd916..0af2236a456bb0 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -43,7 +43,6 @@ class Settings setup_makes_kernel_gem_public silence_deprecations silence_root_warning - suppress_install_using_messages update_requires_all_flag ].freeze diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index 69804a2e6334d3..f7f5ea7865dc60 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -100,7 +100,7 @@ def earlier_version?(spec_version, locked_spec_version) end def print_using_message(message) - if !message.include?("(was ") && Bundler.feature_flag.suppress_install_using_messages? + if !message.include?("(was ") Bundler.ui.debug message else Bundler.ui.info message diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index f7ad6057b46b79..4a9f3731bd1f56 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -69,19 +69,7 @@ def eql?(other) def to_s begin - at = if local? - path - elsif user_ref = options["ref"] - if /\A[a-z0-9]{4,}\z/i.match?(ref) - shortref_for_display(user_ref) - else - user_ref - end - elsif ref - ref - else - current_branch - end + at = humanized_ref || current_branch rev = "at #{at}@#{shortref_for_display(revision)}" rescue GitError @@ -91,6 +79,10 @@ def to_s uri_with_specifiers([rev, glob_for_display]) end + def identifier + uri_with_specifiers([humanized_ref, cached_revision, glob_for_display]) + end + def uri_with_specifiers(specifiers) specifiers.compact! @@ -256,6 +248,20 @@ def local? private + def humanized_ref + if local? + path + elsif user_ref = options["ref"] + if /\A[a-z0-9]{4,}\z/i.match?(ref) + shortref_for_display(user_ref) + else + user_ref + end + elsif ref + ref + end + end + def serialize_gemspecs_in(destination) destination = destination.expand_path(Bundler.root) if destination.relative? Dir["#{destination}/#{@glob}"].each do |spec_path| diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index fa2da5e088a234..8ad034984ba23e 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = "2.4.16".freeze + VERSION = "2.4.17".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 c845554453f1fb..73233499ed8ea4 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require "rbconfig" module Gem - VERSION = "3.4.16" + VERSION = "3.4.17" end # Must be first since it unloads the prelude from 1.9.2 diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index 5e18be50ef21a3..a76d115e0323ef 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -147,6 +147,8 @@ def find_all(req) res << Gem::Resolver::InstalledSpecification.new(self, gemspec) end unless @ignore_installed + matching_local = [] + if consider_local? matching_local = @local.values.select do |spec, _| req.match? spec @@ -167,7 +169,7 @@ def find_all(req) end end - res.concat @remote_set.find_all req if consider_remote? + res.concat @remote_set.find_all req if consider_remote? && matching_local.empty? res end diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 4a720a9120c843..84042709bf0269 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -772,7 +772,7 @@ end end - it "shows the previous version of the gem when updated from rubygems source", :bundler => "< 3" do + it "shows the previous version of the gem when updated from rubygems source" do build_repo2 install_gemfile <<-G @@ -780,7 +780,7 @@ gem "activesupport" G - bundle "update", :all => true + bundle "update", :all => true, :verbose => true expect(out).to include("Using activesupport 2.3.5") update_repo2 do @@ -791,32 +791,28 @@ expect(out).to include("Installing activesupport 3.0 (was 2.3.5)") end - context "with suppress_install_using_messages set" do - before { bundle "config set suppress_install_using_messages true" } - - it "only prints `Using` for versions that have changed" do - build_repo4 do - build_gem "bar" - build_gem "foo" - end - - install_gemfile <<-G - source "#{file_uri_for(gem_repo4)}" - gem "bar" - gem "foo" - G + it "only prints `Using` for versions that have changed" do + build_repo4 do + build_gem "bar" + build_gem "foo" + end - bundle "update", :all => true - expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/) + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "bar" + gem "foo" + G - update_repo4 do - build_gem "foo", "2.0" - end + bundle "update", :all => true + expect(out).to match(/Resolving dependencies\.\.\.\.*\nBundle updated!/) - bundle "update", :all => true - out.sub!("Removing foo (1.0)\n", "") - expect(out).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/) + update_repo4 do + build_gem "foo", "2.0" end + + bundle "update", :all => true + out.sub!("Removing foo (1.0)\n", "") + expect(out).to match(/Resolving dependencies\.\.\.\.*\nFetching foo 2\.0 \(was 1\.0\)\nInstalling foo 2\.0 \(was 1\.0\)\nBundle updated/) end it "shows error message when Gemfile.lock is not preset and gem is specified" do @@ -1386,7 +1382,7 @@ gem "rack" G - bundle :update, :bundler => "2.3.0.dev" + bundle :update, :bundler => "2.3.0.dev", :verbose => "true" # Only updates properly on modern RubyGems. @@ -1423,7 +1419,7 @@ gem "rack" G - bundle :update, :bundler => "2.3.9", :raise_on_error => false + bundle :update, :bundler => "2.3.9", :raise_on_error => false, :verbose => true expect(out).not_to include("Fetching gem metadata from https://rubygems.org/") diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index c96a78bc1cff22..910f96f4ab2aa7 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -30,6 +30,13 @@ expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes :size => 1 end + it "does not write to cache on bundler/setup" do + cache_path = default_bundle_path.join("cache") + FileUtils.rm_rf(cache_path) + ruby "require 'bundler/setup'" + expect(cache_path).not_to exist + end + it "caches the git repo globally and properly uses the cached repo on the next invocation" do simulate_new_machine bundle "config set global_gem_cache true" diff --git a/spec/bundler/install/git_spec.rb b/spec/bundler/install/git_spec.rb index 10c4bd73d96bf5..882f2a2d422767 100644 --- a/spec/bundler/install/git_spec.rb +++ b/spec/bundler/install/git_spec.rb @@ -147,8 +147,6 @@ #{Bundler::VERSION} L - original_lockfile = lockfile - # If GH#6743 is present, the first `bundle install` will change the # lockfile, by flipping the order (`other` would be moved to the top). # diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index 2b0b874b2d6727..c0ed8b9467a252 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -475,6 +475,40 @@ def test_install_local_dependency_installed assert_equal %w[b-1], inst.installed_gems.map {|s| s.full_name } end + def test_install_local_dependency_no_network_for_target_gem + a1, a1_gem = util_gem "a", "1" + _, b1_gem = util_gem "b", "1" do |s| + s.add_dependency "a" + end + + util_setup_spec_fetcher(a1) + + a1_data = Gem.read_binary(a1_gem) + @fetcher.data["http://gems.example.com/gems/a-1.gem"] = a1_data + + # compact index is available + compact_index_response = Net::HTTPResponse.new "1.1", 200, "OK" + compact_index_response.uri = URI("http://gems.example.com") + @fetcher.data["http://gems.example.com/"] = compact_index_response + + # but private local gem not present there + @fetcher.data["http://gems.example.com/info/b"] = + proc do + raise "should not happen" + end + + FileUtils.mv b1_gem, @tempdir + + inst = nil + + Dir.chdir @tempdir do + inst = Gem::DependencyInstaller.new + inst.install "b-1.gem" + end + + assert_equal %w[a-1 b-1], inst.installed_gems.map(&:full_name) + end + def test_install_local_subdir util_setup_gems diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb index aba9dc54479bd2..4845e31e5bdb67 100644 --- a/test/rubygems/test_gem_request.rb +++ b/test/rubygems/test_gem_request.rb @@ -2,7 +2,6 @@ require_relative "helper" require "rubygems/request" require "ostruct" -require "base64" unless Gem::HAVE_OPENSSL warn "Skipping Gem::Request tests. openssl not found." @@ -20,6 +19,12 @@ def make_request(uri, request_class, last_modified, proxy) Gem::Request.create_with_proxy uri, request_class, last_modified, proxy end + # This method is same code as Base64.encode64 + # We should not use Base64.encode64 because we need to avoid gem activation. + def base64_encode64(bin) + [bin].pack("m") + end + def setup @proxies = %w[http_proxy https_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY] @old_proxies = @proxies.map {|k| ENV[k] } @@ -208,7 +213,7 @@ def test_fetch_basic_auth end auth_header = conn.payload["Authorization"] - assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header + assert_equal "Basic #{base64_encode64('user:pass')}".strip, auth_header assert_includes @ui.output, "GET https://user:REDACTED@example.rubygems/specs.#{Gem.marshal_version}" end @@ -225,7 +230,7 @@ def test_fetch_basic_auth_encoded end auth_header = conn.payload["Authorization"] - assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header + assert_equal "Basic #{base64_encode64('user:{DEScede}pass')}".strip, auth_header assert_includes @ui.output, "GET https://user:REDACTED@example.rubygems/specs.#{Gem.marshal_version}" end @@ -242,7 +247,7 @@ def test_fetch_basic_oauth_encoded end auth_header = conn.payload["Authorization"] - assert_equal "Basic #{Base64.encode64('{DEScede}pass:x-oauth-basic')}".strip, auth_header + assert_equal "Basic #{base64_encode64('{DEScede}pass:x-oauth-basic')}".strip, auth_header assert_includes @ui.output, "GET https://REDACTED:x-oauth-basic@example.rubygems/specs.#{Gem.marshal_version}" end diff --git a/tool/bundler/dev_gems.rb.lock b/tool/bundler/dev_gems.rb.lock index 834ca8d942ee14..e28adfb8fef946 100644 --- a/tool/bundler/dev_gems.rb.lock +++ b/tool/bundler/dev_gems.rb.lock @@ -54,4 +54,4 @@ DEPENDENCIES webrick (~> 1.6) BUNDLED WITH - 2.4.16 + 2.4.17 diff --git a/tool/bundler/rubocop_gems.rb.lock b/tool/bundler/rubocop_gems.rb.lock index 924b62c1ec1e8a..f414357da5897e 100644 --- a/tool/bundler/rubocop_gems.rb.lock +++ b/tool/bundler/rubocop_gems.rb.lock @@ -70,4 +70,4 @@ DEPENDENCIES test-unit BUNDLED WITH - 2.4.16 + 2.4.17 diff --git a/tool/bundler/standard_gems.rb.lock b/tool/bundler/standard_gems.rb.lock index bbf2baedbb2426..89aed045da35d1 100644 --- a/tool/bundler/standard_gems.rb.lock +++ b/tool/bundler/standard_gems.rb.lock @@ -78,4 +78,4 @@ DEPENDENCIES test-unit BUNDLED WITH - 2.4.16 + 2.4.17 diff --git a/tool/bundler/test_gems.rb.lock b/tool/bundler/test_gems.rb.lock index da7ab3dbd8ee35..2bf7107b214c5b 100644 --- a/tool/bundler/test_gems.rb.lock +++ b/tool/bundler/test_gems.rb.lock @@ -42,4 +42,4 @@ DEPENDENCIES webrick (= 1.7.0) BUNDLED WITH - 2.4.16 + 2.4.17