Check blacklisted Casks when auditing.
In some cases, certain Casks shouldn't be resubmitted for specific reasons: difficult to maintain, developers maintain their own version, ... To make sure these cases are restricted - we can add them to a blacklist and have the blacklist checked as part of the `brew cask audit` steps.
This commit is contained in:
parent
d40a4173d4
commit
af10d13381
@ -1,5 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cask/blacklist"
|
||||||
require "cask/checkable"
|
require "cask/checkable"
|
||||||
require "cask/download"
|
require "cask/download"
|
||||||
require "digest"
|
require "digest"
|
||||||
@ -30,6 +31,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run!
|
def run!
|
||||||
|
check_blacklist
|
||||||
check_required_stanzas
|
check_required_stanzas
|
||||||
check_version
|
check_version
|
||||||
check_sha256
|
check_sha256
|
||||||
@ -320,6 +322,13 @@ module Cask
|
|||||||
add_error "appcast at URL '#{appcast_stanza}' offline or looping"
|
add_error "appcast at URL '#{appcast_stanza}' offline or looping"
|
||||||
end
|
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
|
def check_https_availability
|
||||||
return unless download
|
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
|
||||||
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
|
describe "latest with auto_updates checks" do
|
||||||
let(:warning_msg) { "Casks with `version :latest` should not use `auto_updates`" }
|
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
|
context "when an exception is raised" do
|
||||||
let(:cask) { instance_double(Cask::Cask) }
|
let(:cask) { instance_double(Cask::Cask) }
|
||||||
|
|
||||||
it "does not fail" do
|
it "fails the audit" do
|
||||||
expect(cask).to receive(:version).and_raise(StandardError.new)
|
expect(cask).to receive(:tap).and_raise(StandardError.new)
|
||||||
expect(subject).to fail_with(/exception while auditing/)
|
expect(subject).to fail_with(/exception while auditing/)
|
||||||
end
|
end
|
||||||
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