diff options
author | Hiroshi SHIBATA <[email protected]> | 2020-12-15 08:32:54 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2020-12-15 10:54:09 +0900 |
commit | 2fa9f3c0322570dfb1672b49bc1f3306ef595131 () | |
tree | bdb2889c822e634f931d27f2ca81c6192e6e5b0e | |
parent | 7898f4243f5df9ead0bf91cc8c40907c559d18c0 (diff) |
Prepare to release rubygems-3.2.1 and bundler-2.2.1
Notes: Merged: https://.com/ruby/ruby/pull/3901
27 files changed, 329 insertions, 129 deletions
@@ -212,6 +212,15 @@ module Bundler end end def ruby_scope "#{Bundler.rubygems.ruby_engine}/#{RbConfig::CONFIG["ruby_version"]}" end @@ -602,8 +611,9 @@ EOF reset_rubygems! end - def reset_settings! @settings = nil end def reset_paths! @@ -57,7 +57,7 @@ module Bundler custom_gemfile = options[:gemfile] || Bundler.settings[:gemfile] if custom_gemfile && !custom_gemfile.empty? Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", File.expand_path(custom_gemfile) - Bundler.reset_settings! end Bundler.settings.set_command_option_if_given :retry, options[:retry] @@ -76,6 +76,8 @@ module Bundler next unless gems.empty? || gems.include?(current_spec.name) active_spec = retrieve_active_spec(definition, current_spec) next unless filter_options_.empty? || update_present_via_semver_portions(current_spec, active_spec, options) gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version) @@ -229,8 +231,6 @@ module Bundler end def update_present_via_semver_portions(current_spec, active_spec, options) - return false if active_spec.nil? - current_major = current_spec.version.segments.first active_major = active_spec.version.segments.first @@ -269,7 +269,9 @@ module Bundler else # Run a resolve against the locally available gems Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}") - last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms) end # filter out gems that _can_ be installed on multiple platforms, but don't need @@ -548,11 +550,7 @@ module Bundler private def add_current_platform - current_platforms.each {|platform| add_platform(platform) } - end - - def current_platforms - [local_platform, generic_local_platform].uniq end def change_reason @@ -847,14 +845,6 @@ module Bundler @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) } end - # This list of dependencies is only used in #resolve, so it's OK to add - # the metadata dependencies here - def expanded_dependencies - @expanded_dependencies ||= begin - expand_dependencies(dependencies + metadata_dependencies, @remote) - end - end - def metadata_dependencies @metadata_dependencies ||= begin ruby_versions = ruby_version_requirements(@ruby_version) @@ -881,7 +871,8 @@ module Bundler end end - def expand_dependencies(dependencies, remote = false) deps = [] dependencies.each do |dep| dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name) @@ -96,9 +96,11 @@ module Bundler def gem_platforms(valid_platforms) return valid_platforms if @platforms.empty? @gem_platforms ||= expanded_platforms.compact.uniq - valid_platforms & @gem_platforms end def expanded_platforms @@ -82,7 +82,7 @@ module Bundler search_object = if source.is_a?(Source::Path) Dependency.new(name, version) else - self end platform_object = Gem::Platform.new(platform) candidates = source.specs.search(search_object) @@ -129,5 +129,19 @@ module Bundler @specification.send(method, *args, &blk) end end end @@ -75,7 +75,7 @@ module Bundler return unless debug? debug_info = yield debug_info = debug_info.inspect unless debug_info.is_a?(String) - warn debug_info.split("\n").map {|s| "BUNDLER: " + " " * depth + s } end def debug? @@ -106,18 +106,19 @@ module Bundler specification.dependencies_for_activated_platforms end - def search_for(dependency) - platform = dependency.__platform - dependency = dependency.dep unless dependency.is_a? Gem::Dependency - search = @search_for[dependency] ||= begin index = index_for(dependency) - results = index.search(dependency, @base[dependency.name]) - if vertex = @base_dg.vertex_named(dependency.name) locked_requirement = vertex.payload.requirement end - if !@prerelease_specified[dependency.name] && (!@use_gvp || locked_requirement.nil?) # Move prereleases to the beginning of the list, so they're considered # last during resolution. pre, results = results.partition {|spec| spec.version.prerelease? } @@ -145,31 +146,25 @@ module Bundler end # GVP handles major itself, but it's still a bit risky to trust it with it # until we get it settled with new behavior. For 2.x it can take over all cases. - if !@use_gvp spec_groups else @gem_version_promoter.sort_versions(dependency, spec_groups) end - end - selected_sgs = [] - search.each do |sg| - next unless sg.for?(platform) - # Add a spec group for "non platform specific spec" as the fallback - # spec group. - sg_ruby = sg.copy_for(Gem::Platform::RUBY) - selected_sgs << sg_ruby if sg_ruby - sg_all_platforms = nil - all_platforms = @platforms + [platform] - self.class.sort_platforms(all_platforms).reverse_each do |other_platform| - if sg_all_platforms.nil? - sg_all_platforms = sg.copy_for(other_platform) - else - sg_all_platforms.activate_platform!(other_platform) - end end - selected_sgs << sg_all_platforms end - selected_sgs end def index_for(dependency) @@ -6,7 +6,7 @@ module Bundler include GemHelpers attr_accessor :name, :version, :source - attr_accessor :ignores_bundler_dependencies def initialize(all_specs) @all_specs = all_specs @@ -32,17 +32,13 @@ module Bundler end.compact.uniq end - def activate_platform!(platform) - return unless for?(platform) - return if @activated_platforms.include?(platform) - @activated_platforms << platform - end - def copy_for(platform) copied_sg = self.class.new(@all_specs) copied_sg.ignores_bundler_dependencies = @ignores_bundler_dependencies - return nil unless copied_sg.for?(platform) - copied_sg.activate_platform!(platform) copied_sg end @@ -565,7 +565,6 @@ module Bundler end def all_specs - require_relative "remote_specification" Gem::Specification.stubs.map do |stub| StubSpecification.from_stub(stub) end @@ -1,7 +1,5 @@ # frozen_string_literal: true -require_relative "remote_specification" - module Bundler class StubSpecification < RemoteSpecification def self.from_stub(stub) @@ -159,7 +159,14 @@ class Bundler::Persistent::Net::HTTP::Persistent # limits (typically windows). if Process.const_defined? :RLIMIT_NOFILE - DEFAULT_POOL_SIZE = Process.getrlimit(Process::RLIMIT_NOFILE).first / 4 else DEFAULT_POOL_SIZE = 256 end @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = "2.2.0".freeze def self.bundler_major_version @bundler_major_version ||= VERSION.split(".").first.to_i @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = "3.2.0".freeze end # Must be first since it unloads the prelude from 1.9.2 @@ -52,7 +52,7 @@ class Gem::Resolver::APISet < Gem::Resolver::Set end versions(req.name).each do |ver| - if req.dependency.match? req.name, ver[:number] res << Gem::Resolver::APISpecification.new(self, ver) end end @@ -148,6 +148,7 @@ class Gem::Source spec = Gem::Util.inflate spec if update_cache? FileUtils.mkdir_p cache_dir File.open local_spec, 'wb' do |io| @@ -7,10 +7,10 @@ using Module.new { # non-tty. refine Spec::Helpers do def out - super.gsub(/.[\b]/, '') end end -} RSpec.describe "bundle executable" do it "returns non-zero exit status when passed unrecognized options" do @@ -34,45 +34,7 @@ RSpec.describe Bundler::Definition do end describe "detects changes" do - it "for a path gem with changes", :bundler => "< 3" do - build_lib "foo", "1.0", :path => lib_path("foo") - - install_gemfile <<-G - source "#{file_uri_for(gem_repo1)}" - gem "foo", :path => "#{lib_path("foo")}" - G - - build_lib "foo", "1.0", :path => lib_path("foo") do |s| - s.add_dependency "rack", "1.0" - end - - bundle :install, :env => { "DEBUG" => "1" } - - expect(out).to match(/re-resolving dependencies/) - lockfile_should_be <<-G - PATH - remote: #{lib_path("foo")} - specs: - foo (1.0) - rack (= 1.0) - - GEM - remote: #{file_uri_for(gem_repo1)}/ - specs: - rack (1.0.0) - - PLATFORMS - #{lockfile_platforms} - - DEPENDENCIES - foo! - - BUNDLED WITH - #{Bundler::VERSION} - G - end - - it "for a path gem with changes", :bundler => "3" do build_lib "foo", "1.0", :path => lib_path("foo") install_gemfile <<-G @@ -311,6 +311,8 @@ RSpec.describe "bundle check" do end before do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -336,9 +338,10 @@ RSpec.describe "bundle check" do context "is older" do it "does not change the lock" do - lockfile lock_with("1.10.1") - bundle :check, :raise_on_error => false - lockfile_should_be lock_with("1.10.1") end end end @@ -938,6 +938,49 @@ __FILE__: #{path.to_s.inspect} end end context "with a system gem that shadows a default gem" do let(:openssl_version) { "99.9.9" } let(:expected) { ruby "gem 'openssl', '< 999999'; require 'openssl'; puts OpenSSL::VERSION", :artifice => nil, :raise_on_error => false } @@ -429,6 +429,17 @@ RSpec.describe "bundle outdated" do expect(out).to end_with(expected_output) end it "only reports gem dependencies when they can actually be updated" do install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" @@ -9,36 +9,67 @@ RSpec.describe "bundle install with specific platforms" do context "when on a darwin machine" do before { simulate_platform "x86_64-darwin-15" } - it "locks to both the specific darwin platform and ruby" do setup_multiplatform_gem install_gemfile(google_protobuf) allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")]) expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin") expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[ - google-protobuf-3.0.0.alpha.5.0.5.1 google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin ]) end - it "caches both the universal-darwin and ruby gems when --all-platforms is passed and properly picks them up on further bundler invocations" do setup_multiplatform_gem gemfile(google_protobuf) bundle "cache --all-platforms" - expect([cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1"), cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin")]). - to all(exist) bundle "install --verbose" expect(err).to be_empty end - it "caches both the universal-darwin and ruby gems when cache_all_platforms is configured and properly picks them up on further bundler invocations" do setup_multiplatform_gem gemfile(google_protobuf) bundle "config set --local cache_all_platforms true" bundle "cache" - expect([cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1"), cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin")]). - to all(exist) bundle "install --verbose" expect(err).to be_empty @@ -87,10 +118,9 @@ RSpec.describe "bundle install with specific platforms" do G allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) - expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")]) expect(the_bundle).to include_gems("facter 2.4.6 universal-darwin", "CFPropertyList 1.0") expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(["CFPropertyList-1.0", - "facter-2.4.6", "facter-2.4.6-universal-darwin"]) end @@ -104,9 +134,8 @@ RSpec.describe "bundle install with specific platforms" do install_gemfile(google_protobuf) bundle "lock --add-platform=#{x64_mingw}" - expect(the_bundle.locked_gems.platforms).to eq([rb, x64_mingw, pl("x86_64-darwin-15")]) expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[ - google-protobuf-3.0.0.alpha.5.0.5.1 google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin google-protobuf-3.0.0.alpha.5.0.5.1-x64-mingw32 ]) @@ -117,7 +146,7 @@ RSpec.describe "bundle install with specific platforms" do install_gemfile(google_protobuf) bundle "lock --add-platform=#{java}" - expect(the_bundle.locked_gems.platforms).to eq([java, rb, pl("x86_64-darwin-15")]) expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(%w[ google-protobuf-3.0.0.alpha.5.0.5.1 google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin @@ -116,7 +116,7 @@ RSpec.describe "bundle install with install-time dependencies" do bundle :install, :env => { "BUNDLER_DEBUG_RESOLVER" => "1" } - expect(err).to include("BUNDLER: Starting resolution") end end @@ -130,7 +130,7 @@ RSpec.describe "bundle install with install-time dependencies" do bundle :install, :env => { "DEBUG_RESOLVER" => "1" } - expect(err).to include("BUNDLER: Starting resolution") end end @@ -147,7 +147,7 @@ RSpec.describe "bundle install with install-time dependencies" do activated_groups = "net_b (1.0) (ruby)" activated_groups += ", net_b (1.0) (#{local_platforms.join(", ")})" if local_platforms.any? && local_platforms != ["ruby"] - expect(err).to include(" net_b"). and include("BUNDLER: Starting resolution"). and include("BUNDLER: Finished resolution"). and include("Attempting to activate [#{activated_groups}]") @@ -981,7 +981,7 @@ RSpec.describe "the lockfile format" do G end - it "persists the spec's platform and specific platform to the lockfile" do build_repo2 do build_gem "platform_specific", "1.0" do |s| s.platform = Gem::Platform.new("universal-java-16") @@ -999,11 +999,9 @@ RSpec.describe "the lockfile format" do GEM remote: #{file_uri_for(gem_repo2)}/ specs: - platform_specific (1.0-java) platform_specific (1.0-universal-java-16) PLATFORMS - java universal-java-16 DEPENDENCIES @@ -345,4 +345,115 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do expect(err).to include("You have one or more invalid gemspecs that need to be fixed.") expect(err).to include("resque-scheduler 2.2.0 has an invalid gemspec") end end @@ -56,6 +56,7 @@ class BundlerVCRHTTP < Net::HTTP response = http.request_without_vcr(request, body, &response_block) @recording = false unless @recording FileUtils.mkdir_p(File.dirname(request_path)) binwrite(request_path, request_to_string(request)) binwrite(response_path, response_to_string(response)) @@ -94,7 +94,7 @@ module Spec end def local_platforms - [local, specific_local_platform].uniq end end end @@ -55,6 +55,35 @@ class TestGemResolverAPISet < Gem::TestCase assert_equal expected, set.find_all(a_dep) end def test_find_all_cache spec_fetcher |