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 |
apainintheneck
left a comment
There was a problem hiding this comment.
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 |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
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 |
|
Great work here! |
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith 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
CaskLoadermethods: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, ifslackwas installed fromtest/tap, runningload_installed_cask("slack")will return thetest/tap/slackcask and not thehomebrew/cask/slackcask. 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::caskswill 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-namewill 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/hellois installed,brew uninstall homebrew/core/hellowill not uninstall the formula.brew uninstall helloandbrew uninstall test/tap/hellowill still work as expected.