Merge pull request #8302 from MLH-Fellowship/deprecate-cask-cmds

home: Deprecate brew cask home
This commit is contained in:
Mike McQuaid 2020-08-14 17:15:05 +01:00 committed by GitHub
commit 535e7dc836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 19 deletions

View File

@ -8,6 +8,8 @@ module Cask
end
def run
# odeprecated "brew cask home", "brew home"
if casks.none?
odebug "Opening project homepage"
self.class.open_url "https://brew.sh/"

View File

@ -25,7 +25,10 @@ module Homebrew
end
homepages = args.formulae_and_casks.map do |formula_or_cask|
puts "Opening homepage for #{name_of(formula_or_cask)}"
disclaimer = disclaimers(formula_or_cask)
disclaimer = " (#{disclaimer})" if disclaimer.present?
puts "Opening homepage for #{name_of(formula_or_cask)}#{disclaimer}"
formula_or_cask.homepage
end
@ -39,4 +42,15 @@ module Homebrew
"Cask #{formula_or_cask.token}"
end
end
def disclaimers(formula_or_cask)
return unless formula_or_cask.is_a? Formula
begin
cask = Cask::CaskLoader.load formula_or_cask.name
"for the cask, use #{cask.tap.name}/#{cask.token}"
rescue Cask::CaskUnavailableError
nil
end
end
end

View File

@ -8,20 +8,4 @@ describe Cask::Cmd::Home, :cask do
end
it_behaves_like "a command that handles invalid options"
it "opens the homepage for the specified Cask" do
expect(described_class).to receive(:open_url).with("https://brew.sh/")
described_class.run("local-caffeine")
end
it "works for multiple Casks" do
expect(described_class).to receive(:open_url).with("https://brew.sh/")
expect(described_class).to receive(:open_url).with("https://transmissionbt.com/")
described_class.run("local-caffeine", "local-transmission")
end
it "opens the project page when no Cask is specified" do
expect(described_class).to receive(:open_url).with("https://brew.sh/")
described_class.run
end
end

View File

@ -20,6 +20,13 @@ describe "brew home", :integration_test do
Cask::CaskLoader.load(local_caffeine_path).homepage
}
it "opens the project page when no formula or cask is specified" do
expect { brew "home", "HOMEBREW_BROWSER" => "echo" }
.to output("https://brew.sh\n").to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
it "opens the homepage for a given Formula" do
setup_test_formula "testballhome"
@ -30,7 +37,7 @@ describe "brew home", :integration_test do
end
it "opens the homepage for a given Cask" do
expect { brew "home", cask_path("local-caffeine"), "HOMEBREW_BROWSER" => "echo" }
expect { brew "home", local_caffeine_path, "HOMEBREW_BROWSER" => "echo" }
.to output(/#{local_caffeine_homepage}/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
@ -39,7 +46,7 @@ describe "brew home", :integration_test do
it "opens the homepages for a given formula and Cask" do
setup_test_formula "testballhome"
expect { brew "home", "testballhome", cask_path("local-caffeine"), "HOMEBREW_BROWSER" => "echo" }
expect { brew "home", "testballhome", local_caffeine_path, "HOMEBREW_BROWSER" => "echo" }
.to output(/#{testballhome_homepage} #{local_caffeine_homepage}/).to_stdout
.and not_to_output.to_stderr
.and be_a_success