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

Add tag_to_cellar method #12980

Merged
merged 2 commits into from Mar 11, 2022
Merged

Conversation

danielnachun
Copy link
Member

This is a relatively minor change that extract the code we currently use to get the cellar from the tag from compatible_locations? into its own method so we can call it directly, and refactors compatible_locations? to use that method, to avoid redundant code. Basic unit tests have also been added for both methods. More complex testing may be difficult without more refactoring because HOMEBREW_CELLAR and HOMEBREW_PREFIX are constants that I didn't see an obvious way to override.

@BrewTestBot
Copy link
Member

Review period will end on 2022-03-11 at 06:34:33 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Mar 10, 2022
@@ -504,14 +504,19 @@ def root_url(var = nil, specs = {})
end
end

sig { params(tag: Utils::Bottles::Tag).returns(T::Boolean) }
def compatible_locations?(tag: Utils::Bottles.tag)
sig { params(tag: Utils::Bottles::Tag).returns(String) }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type signature here is wrong for the return value and causing it to fail in testing. Sometimes it will be a Symbol (:any, :any_skip_relocation), but other times it will be a path (/usr/local etc.). What's the right type signature that covers both of those?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you want T.any(Symbol, Pathname)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this locally, it looks like the return values are either Symbol or String, so I guess that's what we have to use here. Thanks for the pointer about using T.any!

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Some optional style feedback.

Library/Homebrew/software_spec.rb Outdated Show resolved Hide resolved
Library/Homebrew/software_spec.rb Outdated Show resolved Hide resolved
Copy link
Member

@carlocab carlocab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Mike's suggestions here.

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Mar 11, 2022
@BrewTestBot
Copy link
Member

Review period ended.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @danielnachun! Happy to be merged when you're ready.

@danielnachun danielnachun merged commit f0f1eb6 into Homebrew:master Mar 11, 2022
@github-actions github-actions bot added the outdated PR was locked due to age label Apr 11, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2022
@danielnachun danielnachun deleted the add_tag_to_cellar branch July 11, 2022 00:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants