Merge RubyGems-3.3.13 and Bundler-2.3.13

This commit is contained in:
Hiroshi SHIBATA 2022-05-17 11:26:18 +09:00 committed by nagachika
parent 14e4055ab1
commit c7bbed2994
17 changed files with 155 additions and 50 deletions

View file

@ -87,10 +87,11 @@ module Bundler
@platforms = @locked_platforms.dup
@locked_bundler_version = @locked_gems.bundler_version
@locked_ruby_version = @locked_gems.ruby_version
@originally_locked_specs = SpecSet.new(@locked_gems.specs)
if unlock != true
@locked_deps = @locked_gems.dependencies
@locked_specs = SpecSet.new(@locked_gems.specs)
@locked_specs = @originally_locked_specs
@locked_sources = @locked_gems.sources
else
@unlock = {}
@ -255,14 +256,14 @@ module Bundler
# @return [SpecSet] resolved dependencies
def resolve
@resolve ||= begin
last_resolve = converge_locked_specs
if Bundler.frozen_bundle?
Bundler.ui.debug "Frozen, using resolution from the lockfile"
last_resolve
@locked_specs
elsif !unlocking? && nothing_changed?
Bundler.ui.debug("Found no changes, using resolution from the lockfile")
last_resolve
SpecSet.new(filter_specs(@locked_specs, @dependencies.select{|dep| @locked_specs[dep].any? }))
else
last_resolve = converge_locked_specs
# Run a resolve against the locally available gems
Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
@ -464,6 +465,10 @@ module Bundler
private
def filter_specs(specs, deps)
SpecSet.new(specs).for(expand_dependencies(deps, true), false, false)
end
def materialize(dependencies)
specs = resolve.materialize(dependencies)
missing_specs = specs.missing_specs
@ -679,17 +684,17 @@ module Bundler
end
def converge_specs(specs)
deps = []
converged = []
deps = @dependencies.select do |dep|
specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
end
specs.each do |s|
# Replace the locked dependency's source with the equivalent source from the Gemfile
dep = @dependencies.find {|d| s.satisfies?(d) }
if dep && (!dep.source || s.source.include?(dep.source))
deps << dep
end
s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source unless Bundler.frozen_bundle?
s.source = (dep && dep.source) || sources.get(s.source) || sources.default_source
next if @unlock[:sources].include?(s.source.name)
@ -726,8 +731,7 @@ module Bundler
end
end
resolve = SpecSet.new(converged)
SpecSet.new(resolve.for(expand_dependencies(deps, true), false, false).reject{|s| @unlock[:gems].include?(s.name) })
SpecSet.new(filter_specs(converged, deps).reject{|s| @unlock[:gems].include?(s.name) })
end
def metadata_dependencies
@ -804,7 +808,7 @@ module Bundler
def additional_base_requirements_for_resolve
return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
converge_specs(@locked_gems.specs).map do |locked_spec|
converge_specs(@originally_locked_specs).map do |locked_spec|
name = locked_spec.name
dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
DepProxy.get_proxy(dep, locked_spec.platform)

View file

@ -26,8 +26,11 @@ module Bundler
@required_ruby_version ||= _remote_specification.required_ruby_version
end
# A fallback is included because the original version of the specification
# API didn't include that field, so some marshalled specs in the index have it
# set to +nil+.
def required_rubygems_version
@required_rubygems_version ||= _remote_specification.required_rubygems_version
@required_rubygems_version ||= _remote_specification.required_rubygems_version || Gem::Requirement.default
end
def fetch_platform

View file

@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
VERSION = "2.3.12".freeze
VERSION = "2.3.13".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i

View file

@ -8,7 +8,7 @@
require 'rbconfig'
module Gem
VERSION = "3.3.12".freeze
VERSION = "3.3.13".freeze
end
# Must be first since it unloads the prelude from 1.9.2
@ -864,7 +864,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
return @ruby_version if defined? @ruby_version
version = RUBY_VERSION.dup
if defined?(RUBY_DESCRIPTION)
unless defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL != -1
if RUBY_ENGINE == "ruby"
desc = RUBY_DESCRIPTION[/\Aruby #{Regexp.quote(RUBY_VERSION)}([^ ]+) /, 1]
else

View file

@ -12,7 +12,12 @@ class Gem::Commands::OwnerCommand < Gem::Command
def description # :nodoc:
<<-EOF
The owner command lets you add and remove owners of a gem on a push
server (the default is https://rubygems.org).
server (the default is https://rubygems.org). Multiple owners can be
added or removed at the same time, if the flag is given multiple times.
The supported user identifiers are dependant on the push server.
For rubygems.org, both e-mail and handle are supported, even though the
user identifier field is called "email".
The owner of a gem has the permission to push new versions, yank existing
versions or edit the HTML page of the gem. Be careful of who you give push
@ -35,11 +40,11 @@ permission to.
add_otp_option
defaults.merge! :add => [], :remove => []
add_option '-a', '--add EMAIL', 'Add an owner' do |value, options|
add_option '-a', '--add NEW_OWNER', 'Add an owner by user identifier' do |value, options|
options[:add] << value
end
add_option '-r', '--remove EMAIL', 'Remove an owner' do |value, options|
add_option '-r', '--remove OLD_OWNER', 'Remove an owner by user identifier' do |value, options|
options[:remove] << value
end

View file

@ -364,7 +364,9 @@ RSpec.describe "bundle install with gem sources" do
end
it "throws a warning if a gem is added twice in Gemfile without version requirements" do
install_gemfile <<-G, :raise_on_error => false
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rack"
gem "rack"
@ -376,7 +378,9 @@ RSpec.describe "bundle install with gem sources" do
end
it "throws a warning if a gem is added twice in Gemfile with same versions" do
install_gemfile <<-G, :raise_on_error => false
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rack", "1.0"
gem "rack", "1.0"
@ -387,6 +391,22 @@ RSpec.describe "bundle install with gem sources" do
expect(err).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
end
it "throws a warning if a gem is added twice under different platforms and does not crash when using the generated lockfile" do
build_repo2
install_gemfile <<-G
source "#{file_uri_for(gem_repo2)}"
gem "rack", :platform => :jruby
gem "rack"
G
bundle "install"
expect(err).to include("Your Gemfile lists the gem rack (>= 0) more than once.")
expect(err).to include("Remove any duplicate entries and specify the gem only once.")
expect(err).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
end
it "does not throw a warning if a gem is added once in Gemfile and also inside a gemspec as a development dependency" do
build_lib "my-gem", :path => bundled_app do |s|
s.add_development_dependency "my-private-gem"

View file

@ -542,6 +542,40 @@ RSpec.describe "bundle lock" do
bundle "lock --add-platform x86_64-linux", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
end
it "respects lower bound ruby requirements" do
skip "this spec does not work with prereleases because their version is actually lower than their reported `RUBY_VERSION`" if RUBY_PATCHLEVEL == -1
build_repo4 do
build_gem "our_private_gem", "0.1.0" do |s|
s.required_ruby_version = ">= #{RUBY_VERSION}"
end
end
gemfile <<-G
source "https://localgemserver.test"
gem "our_private_gem"
G
lockfile <<-L
GEM
remote: https://localgemserver.test/
specs:
our_private_gem (0.1.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
our_private_gem
BUNDLED WITH
#{Bundler::VERSION}
L
bundle "install", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
end
context "when an update is available" do
let(:repo) { gem_repo2 }

View file

@ -1182,6 +1182,8 @@ RSpec.describe "bundle update --bundler" do
end
it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo, :realworld do
skip "ruby-head has a default Bundler version too high for this spec to work" if RUBY_PATCHLEVEL == -1
pristine_system_gems "bundler-2.3.9"
build_repo4 do
@ -1226,6 +1228,8 @@ RSpec.describe "bundle update --bundler" do
end
it "errors if the explicit target version does not exist", :realworld do
skip "ruby-head has a default Bundler version too high for this spec to work" if RUBY_PATCHLEVEL == -1
pristine_system_gems "bundler-2.3.9"
build_repo4 do

View file

@ -1496,4 +1496,45 @@ RSpec.describe "bundle install with gems on multiple sources" do
L
end
end
context "when default source uses the old API and includes old gems with nil required_rubygems_version" do
before do
build_repo4 do
build_gem "pdf-writer", "1.1.8"
end
path = "#{gem_repo4}/#{Gem::MARSHAL_SPEC_DIR}/pdf-writer-1.1.8.gemspec.rz"
spec = Marshal.load(Bundler.rubygems.inflate(File.binread(path)))
spec.instance_variable_set(:@required_rubygems_version, nil)
File.open(path, "wb") do |f|
f.write Gem.deflate(Marshal.dump(spec))
end
gemfile <<~G
source "https://localgemserver.test"
gem "pdf-writer", "= 1.1.8"
G
end
it "handles that fine" do
bundle "install --verbose", :artifice => "endpoint", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
expect(lockfile).to eq <<~L
GEM
remote: https://localgemserver.test/
specs:
pdf-writer (1.1.8)
PLATFORMS
#{specific_local_platform}
DEPENDENCIES
pdf-writer (= 1.1.8)
BUNDLED WITH
#{Bundler::VERSION}
L
end
end
end

View file

@ -120,7 +120,7 @@ RSpec.shared_examples "bundle install --standalone" do
realworld_system_gems "tsort --version 0.1.0"
necessary_system_gems = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.2.0", "stringio --version 3.0.0"]
necessary_system_gems = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.2.0", "stringio --version 3.0.1"]
necessary_system_gems += ["shellwords --version 0.1.0", "base64 --version 0.1.0", "resolv --version 0.2.1"] if Gem.rubygems_version < Gem::Version.new("3.3.a")
necessary_system_gems += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a")
realworld_system_gems(*necessary_system_gems, :path => scoped_gem_path(bundled_app("bundle")))

View file

@ -1098,22 +1098,24 @@ Also, a list:
Zlib::Deflate.deflate data
end
def util_set_RUBY_VERSION(version, revision = nil, description = nil, engine = "ruby", engine_version = nil)
def util_set_RUBY_VERSION(version, patchlevel, revision, description, engine = "ruby", engine_version = nil)
if Gem.instance_variables.include? :@ruby_version
Gem.send :remove_instance_variable, :@ruby_version
end
@RUBY_VERSION = RUBY_VERSION
@RUBY_PATCHLEVEL = RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
@RUBY_REVISION = RUBY_REVISION if defined?(RUBY_REVISION)
@RUBY_DESCRIPTION = RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
@RUBY_DESCRIPTION = RUBY_DESCRIPTION
@RUBY_ENGINE = RUBY_ENGINE
@RUBY_ENGINE_VERSION = RUBY_ENGINE_VERSION if defined?(RUBY_ENGINE_VERSION)
util_clear_RUBY_VERSION
Object.const_set :RUBY_VERSION, version
Object.const_set :RUBY_REVISION, revision if revision
Object.const_set :RUBY_DESCRIPTION, description if description
Object.const_set :RUBY_PATCHLEVEL, patchlevel
Object.const_set :RUBY_REVISION, revision
Object.const_set :RUBY_DESCRIPTION, description
Object.const_set :RUBY_ENGINE, engine
Object.const_set :RUBY_ENGINE_VERSION, engine_version if engine_version
end
@ -1122,10 +1124,11 @@ Also, a list:
util_clear_RUBY_VERSION
Object.const_set :RUBY_VERSION, @RUBY_VERSION
Object.const_set :RUBY_PATCHLEVEL, @RUBY_PATCHLEVEL if
defined?(@RUBY_PATCHLEVEL)
Object.const_set :RUBY_REVISION, @RUBY_REVISION if
defined?(@RUBY_REVISION)
Object.const_set :RUBY_DESCRIPTION, @RUBY_DESCRIPTION if
defined?(@RUBY_DESCRIPTION)
Object.const_set :RUBY_DESCRIPTION, @RUBY_DESCRIPTION
Object.const_set :RUBY_ENGINE, @RUBY_ENGINE
Object.const_set :RUBY_ENGINE_VERSION, @RUBY_ENGINE_VERSION if
defined?(@RUBY_ENGINE_VERSION)
@ -1133,6 +1136,7 @@ Also, a list:
def util_clear_RUBY_VERSION
Object.send :remove_const, :RUBY_VERSION
Object.send :remove_const, :RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
Object.send :remove_const, :RUBY_REVISION if defined?(RUBY_REVISION)
Object.send :remove_const, :RUBY_DESCRIPTION if defined?(RUBY_DESCRIPTION)
Object.send :remove_const, :RUBY_ENGINE

View file

@ -1106,16 +1106,8 @@ class TestGem < Gem::TestCase
assert_equal Gem::Requirement.default, Gem.env_requirement('qux')
end
def test_self_ruby_version_with_patchlevel_less_ancient_rubies
util_set_RUBY_VERSION '1.8.5'
assert_equal Gem::Version.new('1.8.5'), Gem.ruby_version
ensure
util_restore_RUBY_VERSION
end
def test_self_ruby_version_with_non_mri_implementations
util_set_RUBY_VERSION '2.5.0', 60928, 'jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]'
util_set_RUBY_VERSION '2.5.0', 0, 60928, 'jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]'
assert_equal Gem::Version.new('2.5.0'), Gem.ruby_version
ensure
@ -1123,7 +1115,7 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_version_with_svn_prerelease
util_set_RUBY_VERSION '2.6.0', 63539, 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]'
util_set_RUBY_VERSION '2.6.0', -1, 63539, 'ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-linux]'
assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version
ensure
@ -1131,7 +1123,7 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_version_with_git_prerelease
util_set_RUBY_VERSION '2.7.0', 'b563439274a402e33541f5695b1bfd4ac1085638', 'ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]'
util_set_RUBY_VERSION '2.7.0', -1, 'b563439274a402e33541f5695b1bfd4ac1085638', 'ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]'
assert_equal Gem::Version.new('2.7.0.preview3'), Gem.ruby_version
ensure
@ -1139,7 +1131,7 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_version_with_non_mri_implementations_with_mri_prerelase_compatibility
util_set_RUBY_VERSION '2.6.0', 63539, 'weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]', 'weirdjruby', '9.2.0.0'
util_set_RUBY_VERSION '2.6.0', -1, 63539, 'weirdjruby 9.2.0.0 (2.6.0preview2) 2018-05-24 81156a8 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11 [linux-x86_64]', 'weirdjruby', '9.2.0.0'
assert_equal Gem::Version.new('2.6.0.preview2'), Gem.ruby_version
ensure
@ -1147,7 +1139,7 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_version_with_svn_trunk
util_set_RUBY_VERSION '1.9.2', 23493, 'ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]'
util_set_RUBY_VERSION '1.9.2', -1, 23493, 'ruby 1.9.2dev (2009-05-20 trunk 23493) [x86_64-linux]'
assert_equal Gem::Version.new('1.9.2.dev'), Gem.ruby_version
ensure
@ -1155,7 +1147,7 @@ class TestGem < Gem::TestCase
end
def test_self_ruby_version_with_git_master
util_set_RUBY_VERSION '2.7.0', '5de284ec78220e75643f89b454ce999da0c1c195', 'ruby 2.7.0dev (2019-12-23T01:37:30Z master 5de284ec78) [x86_64-linux]'
util_set_RUBY_VERSION '2.7.0', -1, '5de284ec78220e75643f89b454ce999da0c1c195', 'ruby 2.7.0dev (2019-12-23T01:37:30Z master 5de284ec78) [x86_64-linux]'
assert_equal Gem::Version.new('2.7.0.dev'), Gem.ruby_version
ensure

View file

@ -72,4 +72,4 @@ DEPENDENCIES
webrick (~> 1.6)
BUNDLED WITH
2.3.12
2.3.13

View file

@ -49,7 +49,6 @@ PLATFORMS
universal-java-11
x86_64-darwin-19
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux
DEPENDENCIES
@ -61,4 +60,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
2.3.12
2.3.13

View file

@ -55,7 +55,6 @@ PLATFORMS
universal-java-11
x86_64-darwin-19
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux
DEPENDENCIES
@ -67,4 +66,4 @@ DEPENDENCIES
test-unit
BUNDLED WITH
2.3.12
2.3.13

View file

@ -41,4 +41,4 @@ DEPENDENCIES
webrick (= 1.7.0)
BUNDLED WITH
2.3.12
2.3.13