summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2023-03-17 15:42:28 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-23 17:18:49 +0900
commita9fd1860dd30fff3b6e5ad0d65801f8188019325 (patch)
treed94415927a76a3f2dac64430fb3d8720bf63af28 /lib
parent6ad6ae680a0f92cfa91c727701eb67150ffd4a27 (diff)
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.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7582
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/endpoint_specification.rb4
-rw-r--r--lib/bundler/lazy_specification.rb12
-rw-r--r--lib/bundler/lockfile_parser.rb4
-rw-r--r--lib/bundler/remote_specification.rb6
4 files changed, 7 insertions, 19 deletions
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}"