Skip to content

Commit

Permalink
Merge RubyGems-3.5.20 and Bundler-2.5.20
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Sep 25, 2024
1 parent ecab93c commit f0e8182
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 66 deletions.
6 changes: 5 additions & 1 deletion lib/bundler/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ def run

warn_if_root

Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
if options[:local]
Bundler.self_manager.restart_with_locked_bundler_if_needed
else
Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
end

Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?

Expand Down
32 changes: 15 additions & 17 deletions lib/bundler/cli/outdated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,26 @@ def run
}
end

if outdated_gems.empty?
relevant_outdated_gems = if options_include_groups
outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems|
contains_group = groups.split(", ").include?(options[:group])
next unless options[:groups] || contains_group

gems
end.compact
else
outdated_gems
end

if relevant_outdated_gems.empty?
unless options[:parseable]
Bundler.ui.info(nothing_outdated_message)
end
else
if options_include_groups
relevant_outdated_gems = outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems|
contains_group = groups.split(", ").include?(options[:group])
next unless options[:groups] || contains_group

gems
end.compact

if options[:parseable]
print_gems(relevant_outdated_gems)
else
print_gems_table(relevant_outdated_gems)
end
elsif options[:parseable]
print_gems(outdated_gems)
if options[:parseable]
print_gems(relevant_outdated_gems)
else
print_gems_table(outdated_gems)
print_gems_table(relevant_outdated_gems)
end

exit 1
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def groups

def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
if [true, false, nil].include?(file_or_preserve_unknown_sections)
target_lockfile = lockfile || Bundler.default_lockfile
target_lockfile = lockfile
preserve_unknown_sections = file_or_preserve_unknown_sections
else
target_lockfile = file_or_preserve_unknown_sections
Expand Down
8 changes: 4 additions & 4 deletions lib/bundler/self_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ def restart_with(version)

def needs_switching?
autoswitching_applies? &&
released?(lockfile_version) &&
!running?(lockfile_version) &&
!updating? &&
Bundler.settings[:version] != "system"
Bundler.settings[:version] != "system" &&
released?(restart_version) &&
!running?(restart_version) &&
!updating?
end

def autoswitching_applies?
Expand Down
7 changes: 6 additions & 1 deletion lib/bundler/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def local_override!(path)
end

def specs(*)
set_cache_path!(app_cache_path) if use_app_cache?
set_up_app_cache!(app_cache_path) if use_app_cache?

if requires_checkout? && !@copied
FileUtils.rm_rf(app_cache_path) if use_app_cache? && git_proxy.not_a_bare_repository?
Expand Down Expand Up @@ -320,6 +320,11 @@ def set_install_path!(path)
@install_path = path
end

def set_up_app_cache!(path)
FileUtils.mkdir_p(path.join("refs"))
set_cache_path!(path)
end

def has_app_cache?
cached_revision && super
end
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.5.19".freeze
VERSION = "2.5.20".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 @@ -9,7 +9,7 @@
require "rbconfig"

module Gem
VERSION = "3.5.19"
VERSION = "3.5.20"
end

# Must be first since it unloads the prelude from 1.9.2
Expand Down
28 changes: 28 additions & 0 deletions spec/bundler/cache/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,34 @@
expect(the_bundle).to include_gem "foo 1.0"
end

it "can install after bundle cache without cloning remote repositories with only git tracked files" do
build_git "foo"

gemfile <<-G
source "https://gem.repo1"
gem "foo", :git => '#{lib_path("foo-1.0")}'
G
bundle "config set cache_all true"
bundle :cache, "all-platforms" => true
FileUtils.rm_rf Dir.glob(default_bundle_path("bundler/gems/extensions/**/foo-1.0-*")).first.to_s
FileUtils.rm_rf Dir.glob(default_bundle_path("bundler/gems/foo-1.0-*")).first.to_s

simulate_new_machine
bundle "config set frozen true"
FileUtils.rm_rf "#{default_bundle_path}/cache/bundler/git/foo-1.0-*"

# Remove untracked files (including the empty refs dir in the cache)
Dir.chdir(bundled_app) do
system(*%W[git init --quiet])
system(*%W[git add --all])
system(*%W[git clean -d --force --quiet])
end

bundle "install --local --verbose"
expect(out).to_not include("Fetching")
expect(the_bundle).to include_gem "foo 1.0"
end

it "copies repository to vendor cache" do
# CVE-2022-39253: https://lore.kernel.org/lkml/xmqq4jw1uku5.fsf@gitster.g/
system(*%W[git config --global protocol.file.allow always])
Expand Down
3 changes: 2 additions & 1 deletion spec/bundler/commands/binstubs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
build_gem "prints_loaded_gems", "1.0" do |s|
s.executables = "print_loaded_gems"
s.bindir = "exe"
s.write "exe/print_loaded_gems", <<-R
s.write "exe/print_loaded_gems", <<~R
#!/usr/bin/env ruby
specs = Gem.loaded_specs.values.reject {|s| s.default_gem? }
puts specs.map(&:full_name).sort.inspect
R
Expand Down
8 changes: 8 additions & 0 deletions spec/bundler/commands/outdated_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ def test_group_option(group)
expect(out).to end_with("Bundle up to date!")
end

it "works when only out of date gems are not in given group" do
update_repo2 do
build_gem "terranova", "9"
end
bundle "outdated --group development"
expect(out).to end_with("Bundle up to date!")
end

it "returns a sorted list of outdated gems from one group => 'default'" do
test_group_option("default")

Expand Down
6 changes: 3 additions & 3 deletions spec/bundler/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1202,10 +1202,10 @@
before do
build_repo2 do
build_gem "rails", "3.0.1" do |s|
s.add_dependency "bundler", Bundler::VERSION.succ
s.add_dependency "bundler", "9.9.9"
end

build_gem "bundler", Bundler::VERSION.succ
build_gem "bundler", "9.9.9"
end

gemfile <<-G
Expand All @@ -1218,7 +1218,7 @@
bundle "update", all: true, raise_on_error: false
expect(last_command.stdboth).not_to match(/in snapshot/i)
expect(err).to match(/current Bundler version/i).
and match(/Install the necessary version with `gem install bundler:#{Bundler::VERSION.succ}`/i)
and match(/Install the necessary version with `gem install bundler:9\.9\.9`/i)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/bundler/install/bundler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
before(:each) do
build_repo2 do
build_gem "rails", "3.0" do |s|
s.add_dependency "bundler", ">= 0.9.0.pre"
s.add_dependency "bundler", ">= 0.9.0"
end
build_gem "bundler", "0.9.1"
build_gem "bundler", Bundler::VERSION
Expand Down Expand Up @@ -59,8 +59,8 @@
nice_error = <<~E.strip
Could not find compatible versions
Because rails >= 3.0 depends on bundler >= 0.9.0.pre
and the current Bundler version (#{Bundler::VERSION}) does not satisfy bundler >= 0.9.0.pre, < 1.A,
Because rails >= 3.0 depends on bundler >= 0.9.0
and the current Bundler version (#{Bundler::VERSION}) does not satisfy bundler >= 0.9.0, < 1.A,
rails >= 3.0 requires bundler >= 1.A.
So, because Gemfile depends on rails = 3.0
and Gemfile depends on bundler ~> 0.8,
Expand Down
14 changes: 8 additions & 6 deletions spec/bundler/install/gems/dependency_api_fallback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
# mustermann depends on URI::RFC2396_PARSER behavior
URI.parser = URI::RFC2396_PARSER if URI.respond_to?(:parser=)

require "rackup/server"

@t = Thread.new do
server = Rack::Server.start(app: EndpointTimeout,
Host: "0.0.0.0",
Port: port,
server: "webrick",
AccessLog: [],
Logger: Spec::SilentLogger.new)
server = Rackup::Server.start(app: EndpointTimeout,
Host: "0.0.0.0",
Port: port,
server: "webrick",
AccessLog: [],
Logger: Spec::SilentLogger.new)
server.start
end
@t.run
Expand Down
14 changes: 8 additions & 6 deletions spec/bundler/realworld/gemfile_source_header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ def setup_server

require_relative "../support/artifice/endpoint_mirror_source"

require "rackup/server"

@t = Thread.new do
Rack::Server.start(app: EndpointMirrorSource,
Host: "0.0.0.0",
Port: @port,
server: "webrick",
AccessLog: [],
Logger: Spec::SilentLogger.new)
Rackup::Server.start(app: EndpointMirrorSource,
Host: "0.0.0.0",
Port: @port,
server: "webrick",
AccessLog: [],
Logger: Spec::SilentLogger.new)
end.run

wait_for_server("127.0.0.1", @port)
Expand Down
14 changes: 8 additions & 6 deletions spec/bundler/realworld/mirror_probe_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ def setup_server

require_relative "../support/artifice/endpoint"

require "rackup/server"

@server_thread = Thread.new do
Rack::Server.start(app: Endpoint,
Host: host,
Port: @server_port,
server: "webrick",
AccessLog: [],
Logger: Spec::SilentLogger.new)
Rackup::Server.start(app: Endpoint,
Host: host,
Port: @server_port,
server: "webrick",
AccessLog: [],
Logger: Spec::SilentLogger.new)
end.run

wait_for_server(host, @server_port)
Expand Down
35 changes: 35 additions & 0 deletions spec/bundler/runtime/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,20 @@ def confirm(msg, newline = nil)
expect(out).to include("after: [\"Test_Variable\"]")
end

it "does not create a lockfile" do
script <<-RUBY
require 'bundler/inline'
gemfile do
source "https://gem.repo1"
end
puts Dir.glob("Gemfile.lock")
RUBY

expect(out).to be_empty
end

it "does not load specified version of psych and stringio", :ruby_repo do
build_repo4 do
build_gem "psych", "999"
Expand All @@ -678,4 +692,25 @@ def confirm(msg, newline = nil)
expect(out).to include("The psych gem was resolved to 999")
expect(out).to include("The stringio gem was resolved to 999")
end

it "leaves a lockfile in the same directory as the inline script alone" do
install_gemfile <<~G
source "https://gem.repo1"
gem "foo"
G

original_lockfile = lockfile

script <<-RUBY, env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s }
require "bundler/inline"
gemfile(true) do
source "https://gem.repo1"
gem "myrack"
end
RUBY

expect(lockfile).to eq(original_lockfile)
end
end
22 changes: 22 additions & 0 deletions spec/bundler/runtime/self_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION)
end

it "does not try to install when --local is passed" do
lockfile_bundled_with(previous_minor)
system_gems "myrack-1.0.0", path: default_bundle_path

bundle "install --local"
expect(out).not_to match(/Installing Bundler/)

bundle "-v"
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION)
end

it "shows a discrete message if locked bundler does not exist" do
missing_minor = "#{Bundler::VERSION[0]}.999.999"

Expand Down Expand Up @@ -165,6 +176,17 @@
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION)
end

it "does not try to install when using bundle config version <dev-version>" do
lockfile_bundled_with(previous_minor)

bundle "config set version #{previous_minor}.dev"
bundle "install"
expect(out).not_to match(/restarting using that version/)

bundle "-v"
expect(out).to eq(Bundler::VERSION[0] == "2" ? "Bundler version #{Bundler::VERSION}" : Bundler::VERSION)
end

it "ignores malformed lockfile version" do
lockfile_bundled_with("2.3.")

Expand Down
Loading

0 comments on commit f0e8182

Please sign in to comment.