Merge pull request #6435 from alecclarke/add-cask-blacklist-to-cask-audit
Check blacklisted Casks when auditing.
This commit is contained in:
commit
39dabb4171
@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/blacklist"
|
||||
require "cask/checkable"
|
||||
require "cask/download"
|
||||
require "digest"
|
||||
@ -30,6 +31,7 @@ module Cask
|
||||
end
|
||||
|
||||
def run!
|
||||
check_blacklist
|
||||
check_required_stanzas
|
||||
check_version
|
||||
check_sha256
|
||||
@ -320,6 +322,13 @@ module Cask
|
||||
add_error "appcast at URL '#{appcast_stanza}' offline or looping"
|
||||
end
|
||||
|
||||
def check_blacklist
|
||||
return if cask.tap&.user != "Homebrew"
|
||||
return unless reason = Blacklist.blacklisted_reason(cask.token)
|
||||
|
||||
add_error "#{cask.token} is blacklisted: #{reason}"
|
||||
end
|
||||
|
||||
def check_https_availability
|
||||
return unless download
|
||||
|
||||
|
||||
16
Library/Homebrew/cask/blacklist.rb
Normal file
16
Library/Homebrew/cask/blacklist.rb
Normal file
@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Cask
|
||||
module Blacklist
|
||||
def self.blacklisted_reason(name)
|
||||
case name
|
||||
when /^adobe\-(after|illustrator|indesign|photoshop|premiere)/
|
||||
"Adobe casks were removed because they are too difficult to maintain."
|
||||
when /^audacity$/
|
||||
"Audacity was removed because it is too difficult to download programmatically."
|
||||
when /^pharo$/
|
||||
"Pharo developers maintain their own tap."
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -399,6 +399,28 @@ describe Cask::Audit, :cask do
|
||||
end
|
||||
end
|
||||
|
||||
describe "blacklist checks" do
|
||||
context "when the Cask isn't blacklisted" do
|
||||
let(:cask_token) { "adobe-air" }
|
||||
|
||||
it { is_expected.to pass }
|
||||
end
|
||||
|
||||
context "when the Cask is blacklisted" do
|
||||
context "and it's in the official Homebrew tap" do
|
||||
let(:cask_token) { "adobe-illustrator" }
|
||||
|
||||
it { is_expected.to fail_with(/#{cask_token} is blacklisted: \w+/) }
|
||||
end
|
||||
|
||||
context "and it isn't in the official Homebrew tap" do
|
||||
let(:cask_token) { "pharo" }
|
||||
|
||||
it { is_expected.to pass }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "latest with auto_updates checks" do
|
||||
let(:warning_msg) { "Casks with `version :latest` should not use `auto_updates`" }
|
||||
|
||||
@ -541,8 +563,8 @@ describe Cask::Audit, :cask do
|
||||
context "when an exception is raised" do
|
||||
let(:cask) { instance_double(Cask::Cask) }
|
||||
|
||||
it "does not fail" do
|
||||
expect(cask).to receive(:version).and_raise(StandardError.new)
|
||||
it "fails the audit" do
|
||||
expect(cask).to receive(:tap).and_raise(StandardError.new)
|
||||
expect(subject).to fail_with(/exception while auditing/)
|
||||
end
|
||||
end
|
||||
|
||||
21
Library/Homebrew/test/cask/blacklist_spec.rb
Normal file
21
Library/Homebrew/test/cask/blacklist_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe Cask::Blacklist, :cask do
|
||||
describe "::blacklisted_reason" do
|
||||
matcher :blacklist do |name|
|
||||
match do |expected|
|
||||
expected.blacklisted_reason(name)
|
||||
end
|
||||
end
|
||||
|
||||
it { is_expected.not_to blacklist("adobe-air") }
|
||||
it { is_expected.to blacklist("adobe-after-effects") }
|
||||
it { is_expected.to blacklist("adobe-illustrator") }
|
||||
it { is_expected.to blacklist("adobe-indesign") }
|
||||
it { is_expected.to blacklist("adobe-photoshop") }
|
||||
it { is_expected.to blacklist("adobe-premiere") }
|
||||
it { is_expected.to blacklist("audacity") }
|
||||
it { is_expected.to blacklist("pharo") }
|
||||
it { is_expected.not_to blacklist("non-blacklisted-cask") }
|
||||
end
|
||||
end
|
||||
@ -0,0 +1,10 @@
|
||||
cask 'adobe-air' do
|
||||
version '1.2.3'
|
||||
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
|
||||
|
||||
url 'https://brew.sh/TestCask.dmg'
|
||||
name 'Adobe Air'
|
||||
homepage 'https://brew.sh/'
|
||||
|
||||
app 'TestCask.app'
|
||||
end
|
||||
@ -0,0 +1,10 @@
|
||||
cask 'adobe-illustrator' do
|
||||
version '1.2.3'
|
||||
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
|
||||
|
||||
url 'https://brew.sh/TestCask.dmg'
|
||||
name 'Adobe Illustrator'
|
||||
homepage 'https://brew.sh/'
|
||||
|
||||
app 'TestCask.app'
|
||||
end
|
||||
10
Library/Homebrew/test/support/fixtures/third-party/Casks/pharo.rb
vendored
Normal file
10
Library/Homebrew/test/support/fixtures/third-party/Casks/pharo.rb
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
cask 'pharo' do
|
||||
version '1.2.3'
|
||||
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
|
||||
|
||||
url 'https://brew.sh/ThirdParty.dmg'
|
||||
name 'Pharo'
|
||||
homepage 'https://brew.sh/'
|
||||
|
||||
app 'ThirdParty.app'
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user