This wasn't working before for a few reasons.
1. It never got past the installed name check because the
installed name sets had short names and the tap names were
long names including the tap namespace too. Now we just trim the
long name before comparing it to the installed name set.
Before:
```
["name"].include?("tap/full/name") # always false
```
After:
```
["name"].include("tap/full/name".split("/").last) # sometimes true
```
2. The names we were trying to load formulae and casks with
were incorrect.
Before:
```
tap = Tap.fetch("homebrew/cask-versions")
token = "homebrew/cask-versions/token"
cask = Cask::CaskLoader.load("#{tap}/#{token}")
```
After:
```
token = "homebrew/cask-versions/token"
cask = CaskCaskLoader.load(token)
```
If an installed cask is invalid on attempting an untap: it will
prevent untapping that cask.
Fix this in two ways: one more specific to `untap` and one more
generally to other commands too:
- specific: only read the actual formulae/casks from the tap we're
untapping instead of all of those that are installed
- general: rescue more exceptions in `Cask::Caskroom.casks` (like we
already do for `Formula.installed`
There are plenty of IO operations inside Tap object, and it will be more
when implementing formula alias reverse look up(e.g. list all of alias
names for a formula). So let's cache them.
Some benchmark:
$ time brew info $(brew ruby -e 'puts Formula.tap_names') > /dev/null
Before: 6.40s user 2.42s system 96% cpu 9.134 total
After: 4.75s user 0.77s system 97% cpu 5.637 total
ClosesHomebrew/homebrew#44377.
Signed-off-by: Xu Cheng <xucheng@me.com>
`brew tap` restricts users to GitHub and checks for private repos. I
created `brew any-tap` to support a wider variety of taps.
With very small changes (and no extra flags!), this change allows users
to use `brew tap` with GitHub as they always have or add one extra
argument and tap any repository of any type from anywhere.
brew tap user/name # Same as it ever was
brew tap user/name URL # Tap URL, whatever it happens to be
ClosesHomebrew/homebrew#40326.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>