summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-08-08 14:00:45 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-08-25 11:16:58 -0500
commita8462799055044fefa4c2df707ed1dd52db6c56b (patch)
treeb83075d10795c2a311e1e05c6b88654b7220979f
parent07c76fd07fe827d27ce40d6bf048ebc840330bc8 (diff)
downloadbundler-a8462799055044fefa4c2df707ed1dd52db6c56b.tar.gz
[LockfileParser] Ensure specs are consistently ordered
-rw-r--r--lib/bundler/lazy_specification.rb14
-rw-r--r--lib/bundler/lockfile_parser.rb2
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index f4cd3614b8..0b667f7dbe 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -6,6 +6,20 @@ require "bundler/match_platform"
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 063a1887fa..51148ab614 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -92,7 +92,7 @@ module Bundler
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)