Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/untap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def installed_casks_for(tap:)
next
end

cask if cask.installed?
cask if cask.installed? && cask.tab.tap == tap
end
end

Expand Down
19 changes: 16 additions & 3 deletions Library/Homebrew/test/cmd/untap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class InvalidSpec < Formula

describe "#installed_casks_for", :cask do
shared_examples "finds installed casks in tap", :no_api do
def load_cask(token:, with_cask_file: false, mock_install: false, deprecated: false)
def load_cask(token:, with_cask_file: false, mock_install: false, deprecated: false, tap: subject)
cask_source = <<~RUBY
cask '#{token}' do
version "1.2.3"
Expand All @@ -269,10 +269,10 @@ def load_cask(token:, with_cask_file: false, mock_install: false, deprecated: fa

return if deprecated

cask_loader = Cask::CaskLoader::FromContentLoader.new(cask_source, tap: subject)
cask_loader = Cask::CaskLoader::FromContentLoader.new(cask_source, tap:)
cask = cask_loader.load(config: nil)

InstallHelper.install_with_caskfile(cask) if mock_install
InstallHelper.stub_cask_installation(cask) if mock_install

cask
end
Expand All @@ -295,6 +295,19 @@ def load_cask(token:, with_cask_file: false, mock_install: false, deprecated: fa
it "returns the expected casks" do
expect(described_class.new(%w[arg1]).installed_casks_for(tap: subject)).to eq([currently_installed_cask])
end

it "excludes casks installed from another tap" do
load_cask(token: "other_tap_install", with_cask_file: true, mock_install: true,
tap: subject.core_cask_tap? ? Tap.fetch("homebrew", "bar") : CoreCaskTap.instance)

expect(described_class.new(%w[arg1]).installed_casks_for(tap: subject)).to eq([currently_installed_cask])
end

it "includes installed casks without a receipt" do
(currently_installed_cask.metadata_main_container_path/AbstractTab::FILENAME).unlink

expect(described_class.new(%w[arg1]).installed_casks_for(tap: subject)).to eq([currently_installed_cask])
end
end

context "with core cask tap" do
Expand Down
Loading