Skip to content

Commit

Permalink
Merge RubyGems-3.4.17 and Bundler-2.4.17
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Jul 19, 2023
1 parent eb080ed commit 8759d6c
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 61 deletions.
1 change: 0 additions & 1 deletion lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
3 changes: 0 additions & 3 deletions lib/bundler/man/bundle-config.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions lib/bundler/man/bundle-config.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -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`):
Expand Down
1 change: 0 additions & 1 deletion lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 19 additions & 13 deletions lib/bundler/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!

Expand Down Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/version.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/rubygems/resolver/installer_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
48 changes: 22 additions & 26 deletions spec/bundler/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,15 @@
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
source "#{file_uri_for(gem_repo2)}"
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
Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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/")

Expand Down
7 changes: 7 additions & 0 deletions spec/bundler/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions spec/bundler/install/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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).
#
Expand Down
34 changes: 34 additions & 0 deletions test/rubygems/test_gem_dependency_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 9 additions & 4 deletions test/rubygems/test_gem_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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] }
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tool/bundler/dev_gems.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ DEPENDENCIES
webrick (~> 1.6)

BUNDLED WITH
2.4.16
2.4.17
2 changes: 1 addition & 1 deletion tool/bundler/rubocop_gems.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ DEPENDENCIES
test-unit

BUNDLED WITH
2.4.16
2.4.17
2 changes: 1 addition & 1 deletion tool/bundler/standard_gems.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ DEPENDENCIES
test-unit

BUNDLED WITH
2.4.16
2.4.17
2 changes: 1 addition & 1 deletion tool/bundler/test_gems.rb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ DEPENDENCIES
webrick (= 1.7.0)

BUNDLED WITH
2.4.16
2.4.17

0 comments on commit 8759d6c

Please sign in to comment.