From 18450d5e9e9f4cbbddbb21f854ab6480198a3bfe Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Mon, 8 Aug 2016 14:00:45 -0500 Subject: [PATCH] [LockfileParser] Ensure specs are consistently ordered --- lib/bundler/lazy_specification.rb | 14 ++++++++++++++ lib/bundler/lockfile_parser.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index f4cd3614b83..0b667f7dbe6 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -6,6 +6,20 @@ module Bundler class LazySpecification Identifier = Struct.new(:name, :version, :source, :platform, :dependencies) + class Identifier + include Comparable + def <=>(other) + return unless other.is_a?(Identifier) + [name, version, platform_string] <=> [other.name, other.version, other.platform_string] + end + + protected + + def platform_string + platform_string = platform.to_s + platform_string == Index::RUBY ? Index::NULL : platform_string + end + end include MatchPlatform diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 063a1887fa9..51148ab6141 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -92,7 +92,7 @@ def initialize(lockfile) end end @sources << @rubygems_aggregate - @specs = @specs.values + @specs = @specs.values.sort_by(&:identifier) warn_for_outdated_bundler_version rescue ArgumentError => e Bundler.ui.debug(e)