-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Set correct tap when loading installed casks #17823
Conversation
I accidentally duplicated some of the work in #17821, so this might need to be modified around that PR depending on which route makes more sense |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to named args seem like good sanity checks but it's not obvious to me that they accurately handle migrated/renamed packages or prevent name conflicts when trying to load installed packages. I'm still not sure where or how this should be handled. It doesn't need to be handled in this PR though; I'm just thinking out loud.
We currently have named_args [:installed_formula, :installed_cask]
throughout the codebase but as far as I can tell that information is only really used for documentation and not acted upon anywhere.
In some places, we load formula from kegs or racks and that sort of works but we don't have a good way of doing the same thing for casks yet since that possibility is so new.
Would it be helpful to have a keg for casks that represents the directory in the cask room where the cask has been installed? This would give us easy access to the installed cask file, install receipt and config settings without having to load a cask at all. Naming might be tricky though (shelf, stand, etc.).
The changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks @Rylan12! Feel free to resolve any comments and self-merge when you're ready.
Sorry all, I know there are unanswered questions here and it's been a while. I haven't forgotten and I will return to this in the next two or three days |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
b3d824f
to
711d222
Compare
Sorry for disappearing off the face of the earth for a few weeks... I've made some changes to address the open comments a little bit
Not important to this PR but: these also affect shell completions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Rylan12!
Great work here! |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Fixes #17416
This PR uses the new cask tabs to set the correct tap when loading an installed cask.
I have added two new
CaskLoader
methods:load_installed_cask
: this method is analogous toFormulary::from_keg
. It accepts a token and returns a cask with that token from the tap specified in the install receipt of the cask. Essentially, ifslack
was installed fromtest/tap
, runningload_installed_cask("slack")
will return thetest/tap/slack
cask and not thehomebrew/cask/slack
cask. Note: if a full name is passed, the tap specified in the name will be used, even if a different tap exists in the install receipt.load_from_installed_caskfile
: this method takes an installed caskfile and loads a cask from it, making sure to set the correct tap. If passed a path that isn't an installed caskfile or doesn't exist, it will raise aCaskUnavailableError
.This means that
Cask::Caskroom::casks
will now return the correct casks when a third-party cask is installed and shares a name with a cask inhomebrew/cask
. This means thatbrew list --full-name
will work correctly.Additionally, handling of named arguments when requesting kegs or keg-like-casks (i.e. installed formulae/casks). Now, specifying a full name will raise an error if the installed formula with that short name does not have a matching tap. For example, if
test/tap/hello
is installed,brew uninstall homebrew/core/hello
will not uninstall the formula.brew uninstall hello
andbrew uninstall test/tap/hello
will still work as expected.