diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-01-21 14:35:56 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 14:35:56 +0900 |
commit | 151e469a6259837246d88b3abbb4d9e46ff38b9d (patch) | |
tree | c071c3e89e5d9ce493f754ce0536499373eab286 /lib/bundler | |
parent | 41d0c708122d0f6389410d503b7f4e6342bf56a0 (diff) |
Merge RubyGems 3.2.6 and Bundler 2.2.6 (#4103)
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/definition.rb | 9 | ||||
-rw-r--r-- | lib/bundler/dep_proxy.rb | 23 | ||||
-rw-r--r-- | lib/bundler/gem_version_promoter.rb | 4 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 4 | ||||
-rw-r--r-- | lib/bundler/resolver/spec_group.rb | 6 | ||||
-rw-r--r-- | lib/bundler/rubygems_ext.rb | 16 | ||||
-rw-r--r-- | lib/bundler/spec_set.rb | 2 | ||||
-rw-r--r-- | lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb | 16 | ||||
-rw-r--r-- | lib/bundler/version.rb | 2 |
9 files changed, 52 insertions, 30 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index b22363d119..7683047984 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -818,11 +818,6 @@ module Bundler # commonly happens if the version changed in the gemspec next unless new_spec - new_runtime_deps = new_spec.dependencies.select {|d| d.type != :development } - old_runtime_deps = s.dependencies.select {|d| d.type != :development } - # If the dependencies of the path source have changed and locked spec can't satisfy new dependencies, unlock it - next unless new_runtime_deps.sort == old_runtime_deps.sort || new_runtime_deps.all? {|d| satisfies_locked_spec?(d) } - s.dependencies.replace(new_spec.dependencies) end @@ -897,7 +892,7 @@ module Bundler def expand_dependency_with_platforms(dep, platforms) platforms.map do |p| - DepProxy.new(dep, p) + DepProxy.get_proxy(dep, p) end end @@ -977,7 +972,7 @@ module Bundler next requirements if @locked_gems.dependencies[name] != dependency next requirements if dependency.source.is_a?(Source::Path) dep = Gem::Dependency.new(name, ">= #{locked_spec.version}") - requirements[name] = DepProxy.new(dep, locked_spec.platform) + requirements[name] = DepProxy.get_proxy(dep, locked_spec.platform) requirements end.values end diff --git a/lib/bundler/dep_proxy.rb b/lib/bundler/dep_proxy.rb index bb09fe9ea6..a32dc37b49 100644 --- a/lib/bundler/dep_proxy.rb +++ b/lib/bundler/dep_proxy.rb @@ -4,19 +4,18 @@ module Bundler class DepProxy attr_reader :__platform, :dep + @proxies = {} + + def self.get_proxy(dep, platform) + @proxies[[dep, platform]] ||= new(dep, platform).freeze + end + def initialize(dep, platform) @dep = dep @__platform = platform end - def hash - @hash ||= [dep, __platform].hash - end - - def ==(other) - return false if other.class != self.class - dep == other.dep && __platform == other.__platform - end + private_class_method :new alias_method :eql?, :== @@ -39,6 +38,14 @@ module Bundler s end + def dup + raise NoMethodError.new("DepProxy cannot be duplicated") + end + + def clone + raise NoMethodError.new("DepProxy cannot be cloned") + end + private def method_missing(*args, &blk) diff --git a/lib/bundler/gem_version_promoter.rb b/lib/bundler/gem_version_promoter.rb index 2e87b7d443..3cce3f2139 100644 --- a/lib/bundler/gem_version_promoter.rb +++ b/lib/bundler/gem_version_promoter.rb @@ -81,8 +81,8 @@ module Bundler sort_dep_specs(spec_groups, locked_spec) end.tap do |specs| if DEBUG - warn before_result - warn " after sort_versions: #{debug_format_result(dep, specs).inspect}" + puts before_result + puts " after sort_versions: #{debug_format_result(dep, specs).inspect}" end end end diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 4972d85e08..319f9bb137 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -32,7 +32,7 @@ module Bundler @base_dg = Molinillo::DependencyGraph.new @base.each do |ls| dep = Dependency.new(ls.name, ls.version) - @base_dg.add_vertex(ls.name, DepProxy.new(dep, ls.platform), true) + @base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true) end additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) } @platforms = platforms @@ -75,7 +75,7 @@ module Bundler return unless debug? debug_info = yield debug_info = debug_info.inspect unless debug_info.is_a?(String) - puts debug_info.split("\n").map {|s| "BUNDLER: " + " " * depth + s } + puts debug_info.split("\n").map {|s| depth == 0 ? "BUNDLER: #{s}" : "BUNDLER(#{depth}): #{s}" } end def debug? diff --git a/lib/bundler/resolver/spec_group.rb b/lib/bundler/resolver/spec_group.rb index 34780f9528..1042a2a4a0 100644 --- a/lib/bundler/resolver/spec_group.rb +++ b/lib/bundler/resolver/spec_group.rb @@ -99,7 +99,7 @@ module Bundler spec.dependencies.each do |dep| next if dep.type == :development next if @ignores_bundler_dependencies && dep.name == "bundler".freeze - dependencies[platform] << DepProxy.new(dep, platform) + dependencies[platform] << DepProxy.get_proxy(dep, platform) end end dependencies[platform] @@ -110,10 +110,10 @@ module Bundler return [] unless spec && spec.is_a?(Gem::Specification) dependencies = [] if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none? - dependencies << DepProxy.new(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform) + dependencies << DepProxy.get_proxy(Gem::Dependency.new("Ruby\0", spec.required_ruby_version), platform) end if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none? - dependencies << DepProxy.new(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform) + dependencies << DepProxy.get_proxy(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform) end dependencies end diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 0322b06d07..2bd2dcb451 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -158,6 +158,22 @@ module Gem end end + if Gem::Requirement.new("~> 2.0").hash == Gem::Requirement.new("~> 2.0.0").hash + class Requirement + module CorrectHashForLambdaOperator + def hash + if requirements.any? {|r| r.first == "~>" } + requirements.map {|r| r.first == "~>" ? [r[0], r[1].to_s] : r }.sort.hash + else + super + end + end + end + + prepend CorrectHashForLambdaOperator + end + end + class Platform JAVA = Gem::Platform.new("java") unless defined?(JAVA) MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN) diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index a0b9552c18..951e80231e 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -28,7 +28,7 @@ module Bundler specs_for_dep.first.dependencies.each do |d| next if d.type == :development - d = DepProxy.new(d, dep.__platform) unless match_current_platform + d = DepProxy.get_proxy(d, dep.__platform) unless match_current_platform deps << d end elsif check diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb index 26b8bc745c..f48d333462 100644 --- a/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +++ b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb @@ -329,11 +329,11 @@ module Bundler::Molinillo # Look for past conflicts that could be unwound to affect the # requirement tree for the current conflict + all_reqs = last_detail_for_current_unwind.all_requirements + all_reqs_size = all_reqs.size relevant_unused_unwinds = unused_unwind_options.select do |alternative| - intersecting_requirements = - last_detail_for_current_unwind.all_requirements & - alternative.requirements_unwound_to_instead - next if intersecting_requirements.empty? + diff_reqs = all_reqs - alternative.requirements_unwound_to_instead + next if diff_reqs.size == all_reqs_size # Find the highest index unwind whilst looping through current_detail = alternative if alternative > current_detail alternative @@ -344,8 +344,12 @@ module Bundler::Molinillo state.unused_unwind_options += unwind_details.reject { |detail| detail.state_index == -1 } # Update the requirements_unwound_to_instead on any relevant unused unwinds - relevant_unused_unwinds.each { |d| d.requirements_unwound_to_instead << current_detail.state_requirement } - unwind_details.each { |d| d.requirements_unwound_to_instead << current_detail.state_requirement } + relevant_unused_unwinds.each do |d| + (d.requirements_unwound_to_instead << current_detail.state_requirement).uniq! + end + unwind_details.each do |d| + (d.requirements_unwound_to_instead << current_detail.state_requirement).uniq! + end current_detail end diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 5a49ea546e..b9fd12cda8 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = "2.2.5".freeze + VERSION = "2.2.6".freeze def self.bundler_major_version @bundler_major_version ||= VERSION.split(".").first.to_i |