зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Fix crash when printing resolution conflicts on metadata requirements
https://github.com/rubygems/rubygems/commit/b69e1e9374
This commit is contained in:
Родитель
08cee2bf80
Коммит
633608ebd4
|
@ -19,13 +19,15 @@ module Bundler
|
||||||
# collection of gemspecs is returned. Otherwise, nil is returned.
|
# collection of gemspecs is returned. Otherwise, nil is returned.
|
||||||
def self.resolve(requirements, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
|
def self.resolve(requirements, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
|
||||||
base = SpecSet.new(base) unless base.is_a?(SpecSet)
|
base = SpecSet.new(base) unless base.is_a?(SpecSet)
|
||||||
resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
|
metadata_requirements, regular_requirements = requirements.partition {|dep| dep.name.end_with?("\0") }
|
||||||
|
resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms, metadata_requirements)
|
||||||
result = resolver.start(requirements)
|
result = resolver.start(requirements)
|
||||||
SpecSet.new(SpecSet.new(result).for(requirements.reject {|dep| dep.name.end_with?("\0") }))
|
SpecSet.new(SpecSet.new(result).for(regular_requirements))
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
|
def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms, metadata_requirements)
|
||||||
@source_requirements = source_requirements
|
@source_requirements = source_requirements
|
||||||
|
@metadata_requirements = metadata_requirements
|
||||||
@base = base
|
@base = base
|
||||||
@resolver = Molinillo::Resolver.new(self, self)
|
@resolver = Molinillo::Resolver.new(self, self)
|
||||||
@search_for = {}
|
@search_for = {}
|
||||||
|
@ -344,8 +346,6 @@ module Bundler
|
||||||
trees.sort_by! {|t| t.reverse.map(&:name) }
|
trees.sort_by! {|t| t.reverse.map(&:name) }
|
||||||
end
|
end
|
||||||
|
|
||||||
metadata_requirements = {}
|
|
||||||
|
|
||||||
o << trees.map do |tree|
|
o << trees.map do |tree|
|
||||||
t = "".dup
|
t = "".dup
|
||||||
depth = 2
|
depth = 2
|
||||||
|
@ -354,7 +354,6 @@ module Bundler
|
||||||
base_tree_name = base_tree.name
|
base_tree_name = base_tree.name
|
||||||
|
|
||||||
if base_tree_name.end_with?("\0")
|
if base_tree_name.end_with?("\0")
|
||||||
metadata_requirements[base_tree_name] = base_tree
|
|
||||||
t = nil
|
t = nil
|
||||||
else
|
else
|
||||||
tree.each do |req|
|
tree.each do |req|
|
||||||
|
@ -393,7 +392,7 @@ module Bundler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif name.end_with?("\0")
|
elsif name.end_with?("\0")
|
||||||
o << %(\n Current #{name} version:\n #{SharedHelpers.pretty_dependency(metadata_requirements[name])}\n\n)
|
o << %(\n Current #{name} version:\n #{SharedHelpers.pretty_dependency(@metadata_requirements.find {|req| req.name == name })}\n\n)
|
||||||
elsif conflict.locked_requirement
|
elsif conflict.locked_requirement
|
||||||
o << "\n"
|
o << "\n"
|
||||||
o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
|
o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
|
||||||
|
|
|
@ -282,6 +282,27 @@ RSpec.describe "bundle install with install-time dependencies" do
|
||||||
expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.")
|
expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "gives a meaningful error on ruby version mismatches between dependencies" do
|
||||||
|
build_repo4 do
|
||||||
|
build_gem "requires-old-ruby" do |s|
|
||||||
|
s.required_ruby_version = "< #{RUBY_VERSION}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
build_lib("foo", :path => bundled_app) do |s|
|
||||||
|
s.required_ruby_version = ">= #{RUBY_VERSION}"
|
||||||
|
|
||||||
|
s.add_dependency "requires-old-ruby"
|
||||||
|
end
|
||||||
|
|
||||||
|
install_gemfile <<-G, :raise_on_error => false
|
||||||
|
source "#{file_uri_for(gem_repo4)}"
|
||||||
|
gemspec
|
||||||
|
G
|
||||||
|
|
||||||
|
expect(err).to include("Bundler found conflicting requirements for the Ruby\0 version:")
|
||||||
|
end
|
||||||
|
|
||||||
it "installs the older version under rate limiting conditions" do
|
it "installs the older version under rate limiting conditions" do
|
||||||
build_repo4 do
|
build_repo4 do
|
||||||
build_gem "rack", "9001.0.0" do |s|
|
build_gem "rack", "9001.0.0" do |s|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче