Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Fix error sorting
Browse files Browse the repository at this point in the history
Also avoid mutating the original exception message to generate the message we want
  • Loading branch information
segiddins committed Aug 7, 2018
1 parent 141936b commit 114d9ae
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,8 @@ def metadata_dependencies
concat_ruby_version_requirements(locked_ruby_version_object) unless @unlock[:ruby]
end
[
Dependency.new("ruby\0", ruby_versions),
Dependency.new("rubygems\0", Gem::VERSION),
Dependency.new("Ruby\0", ruby_versions),
Dependency.new("RubyGems\0", Gem::VERSION),
]
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def version_conflict_message(e)
deps = conflict.requirement_trees.map(&:last).flatten(1)
!Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement)))
end
e.conflicts.replace(conflicts) unless conflicts.empty?
e = Molinillo::VersionConflict.new(conflicts, e.specification_provider) unless conflicts.empty?

solver_name = "Bundler"
possibility_type = "gem"
Expand All @@ -329,7 +329,7 @@ def version_conflict_message(e)

trees.reject! {|t| !maximal.include?(t.last) } if maximal

trees.sort_by {|t| [t.flatten.map(&:to_s), t.reverse.map(&:name)] }
trees.sort_by {|t| t.reverse.map(&:name) }
end,
:printable_requirement => lambda {|req| SharedHelpers.pretty_dependency(req) },
:additional_message_for_conflict => lambda do |o, name, conflict|
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/resolver/spec_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ def metadata_dependencies(spec, platform)
return [] if !spec.is_a?(EndpointSpecification) && !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.new(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.new(Gem::Dependency.new("RubyGems\0", spec.required_rubygems_version), platform)
end
dependencies
end
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/source/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class Source
class Metadata < Source
def specs
@specs ||= Index.build do |idx|
idx << Gem::Specification.new("ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
idx << Gem::Specification.new("rubygems\0", Gem::VERSION)
idx << Gem::Specification.new("Ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
idx << Gem::Specification.new("RubyGems\0", Gem::VERSION)

idx << Gem::Specification.new do |s|
s.name = "bundler"
Expand Down
8 changes: 4 additions & 4 deletions spec/install/gems/resolving_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@
expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000")

nice_error = strip_whitespace(<<-E).strip
Bundler found conflicting requirements for the ruby\0 version:
Bundler found conflicting requirements for the Ruby\0 version:
In Gemfile:
ruby\0 (#{error_message_requirement})
Ruby\0 (#{error_message_requirement})
require_ruby was resolved to 1.0, which depends on
ruby\0 (> 9000)
Ruby\0 (> 9000)
ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
E
expect(last_command.bundler_err).to end_with(nice_error)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/resolver/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@
s.required_ruby_version = "~> 2.0.0"
end

gem "ruby\0", "1.8.7"
gem "Ruby\0", "1.8.7"
end
dep "foo"
dep "ruby\0", "1.8.7"
dep "Ruby\0", "1.8.7"

deps = []
@deps.each do |d|
Expand Down
4 changes: 2 additions & 2 deletions spec/support/indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def an_awesome_index
gem "rack-mount", %w[0.4 0.5 0.5.1 0.5.2 0.6]

# --- Pre-release support
gem "rubygems\0", ["1.3.2"]
gem "RubyGems\0", ["1.3.2"]

# --- Rails
versions "1.2.3 2.2.3 2.3.5 3.0.0.beta 3.0.0.beta1" do |version|
Expand Down Expand Up @@ -413,7 +413,7 @@ def optional_prereleases_index
gem("b", %w[0.9.0 1.5.0 2.0.0.pre])

# --- Pre-release support
gem "rubygems\0", ["1.3.2"]
gem "RubyGems\0", ["1.3.2"]
end
end
end
Expand Down

0 comments on commit 114d9ae

Please sign in to comment.