From a9fd1860dd30fff3b6e5ad0d65801f8188019325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 17 Mar 2023 15:42:28 +0100 Subject: Fix flaky when making materialized specs uniq Sometimes we'll have an heterogenous array of specs which include `Gem::Specification` objects, which don't define `#identifier`. Let's use `#full_name` consistently. --- lib/bundler/endpoint_specification.rb | 4 ---- lib/bundler/lazy_specification.rb | 12 ++++-------- lib/bundler/lockfile_parser.rb | 4 ++-- lib/bundler/remote_specification.rb | 6 +----- 4 files changed, 7 insertions(+), 19 deletions(-) (limited to 'lib') diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb index d315d1cc68..863544b1f9 100644 --- a/lib/bundler/endpoint_specification.rb +++ b/lib/bundler/endpoint_specification.rb @@ -26,10 +26,6 @@ module Bundler @platform end - def identifier - @__identifier ||= [name, version, platform.to_s] - end - # needed for standalone, load required_paths from local gemspec # after the gem is installed def require_paths diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 6749892930..ad8191c55f 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -20,7 +20,7 @@ module Bundler end def full_name - if platform == Gem::Platform::RUBY + @full_name ||= if platform == Gem::Platform::RUBY "#{@name}-#{@version}" else "#{@name}-#{@version}-#{platform}" @@ -28,15 +28,15 @@ module Bundler end def ==(other) - identifier == other.identifier + full_name == other.full_name end def eql?(other) - identifier.eql?(other.identifier) + full_name.eql?(other.full_name) end def hash - identifier.hash + full_name.hash end ## @@ -129,10 +129,6 @@ module Bundler end end - def identifier - @__identifier ||= [name, version, platform.to_s] - end - def git_version return unless source.is_a?(Bundler::Source::Git) " #{source.revision[0..6]}" diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 237749c525..97cbf211ba 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -86,7 +86,7 @@ module Bundler send("parse_#{@state}", line) end end - @specs = @specs.values.sort_by(&:identifier) + @specs = @specs.values.sort_by(&:full_name) rescue ArgumentError => e Bundler.ui.debug(e) raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \ @@ -199,7 +199,7 @@ module Bundler @current_spec.source = @current_source @current_source.add_dependency_names(name) - @specs[@current_spec.identifier] = @current_spec + @specs[@current_spec.full_name] = @current_spec elsif spaces.size == 6 version = version.split(",").map(&:strip) if version dep = Gem::Dependency.new(name, version) diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb index 34d7fd116c..7b539b22ae 100644 --- a/lib/bundler/remote_specification.rb +++ b/lib/bundler/remote_specification.rb @@ -29,12 +29,8 @@ module Bundler @platform = _remote_specification.platform end - def identifier - @__identifier ||= [name, version, @platform.to_s] - end - def full_name - if @platform == Gem::Platform::RUBY + @full_name ||= if @platform == Gem::Platform::RUBY "#{@name}-#{@version}" else "#{@name}-#{@version}-#{@platform}" -- cgit v1.2.3