Skip to content

Commit

Permalink
Fix flaky when making materialized specs uniq
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deivid-rodriguez authored and hsbt committed Mar 23, 2023
1 parent 6ad6ae6 commit a9fd186
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
4 changes: 0 additions & 4 deletions lib/bundler/endpoint_specification.rb
Expand Up @@ -26,10 +26,6 @@ def fetch_platform
@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
Expand Down
12 changes: 4 additions & 8 deletions lib/bundler/lazy_specification.rb
Expand Up @@ -20,23 +20,23 @@ def initialize(name, version, platform, source = nil)
end

def full_name
if platform == Gem::Platform::RUBY
@full_name ||= if platform == Gem::Platform::RUBY
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{platform}"
end
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

##
Expand Down Expand Up @@ -129,10 +129,6 @@ def to_s
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]}"
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/lockfile_parser.rb
Expand Up @@ -86,7 +86,7 @@ def initialize(lockfile)
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)}` " \
Expand Down Expand Up @@ -199,7 +199,7 @@ def parse_spec(line)
@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)
Expand Down
6 changes: 1 addition & 5 deletions lib/bundler/remote_specification.rb
Expand Up @@ -29,12 +29,8 @@ def fetch_platform
@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}"
Expand Down

0 comments on commit a9fd186

Please sign in to comment.