Merge pull request #16130 from Bo98/bottle-equality

Implement equality functions for BottleSpecification
This commit is contained in:
Mike McQuaid 2023-10-23 17:08:32 +01:00 committed by GitHub
commit 7b0d46850d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -535,6 +535,12 @@ class BottleSpecification
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)

View File

@ -260,6 +260,11 @@ module Utils
@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.
@ -274,6 +279,11 @@ module Utils
@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)