Skip to content

Commit

Permalink
Merge pull request #16130 from Bo98/bottle-equality
Browse files Browse the repository at this point in the history
Implement equality functions for BottleSpecification
  • Loading branch information
MikeMcQuaid committed Oct 23, 2023
2 parents 35746e0 + de83bc6 commit 7b0d468
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit 7b0d468

Please sign in to comment.