Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement equality functions for BottleSpecification #16130

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions Library/Homebrew/software_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ def root_url(var = nil, specs = {})
end
end

def ==(other)
self.class == other.class && rebuild == other.rebuild && collector == other.collector &&
root_url == other.root_url && root_url_specs == other.root_url_specs && tap == other.tap
end
alias eql? ==

sig { params(tag: Utils::Bottles::Tag).returns(T.any(Symbol, String)) }
def tag_to_cellar(tag = Utils::Bottles.tag)
spec = collector.specification_for(tag)
Expand Down
10 changes: 10 additions & 0 deletions Library/Homebrew/utils/bottles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ def initialize(tag:, checksum:, cellar:)
@checksum = checksum
@cellar = cellar
end

def ==(other)
self.class == other.class && tag == other.tag && checksum == other.checksum && cellar == other.cellar
end
alias eql? ==
end

# Collector for bottle specifications.
Expand All @@ -274,6 +279,11 @@ def tags
@tag_specs.keys
end

def ==(other)
self.class == other.class && @tag_specs == other.instance_variable_get(:@tag_specs)
end
alias eql? ==

sig { params(tag: Utils::Bottles::Tag, checksum: Checksum, cellar: T.any(Symbol, String)).void }
def add(tag, checksum:, cellar:)
spec = Utils::Bottles::TagSpecification.new(tag: tag, checksum: checksum, cellar: cellar)
Expand Down