diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 45c6f3ec3a..cddfc5558e 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -34,7 +34,7 @@ module Hbc check_single_pre_postflight check_single_uninstall_zap check_untrusted_pkg - check_github_releases_appcast + check_hosting_with_appcast check_latest_with_appcast check_stanza_requires_uninstall self @@ -246,13 +246,25 @@ module Hbc add_warning "Casks with an appcast should not use version :latest" end - def check_github_releases_appcast + def check_hosting_with_appcast return if cask.appcast + check_github_releases_appcast + check_sourceforge_appcast + end + + def check_github_releases_appcast return unless cask.url.to_s =~ %r{github.com/([^/]+)/([^/]+)/releases/download/(\S+)} add_warning "Cask uses GitHub releases, please add an appcast. See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/appcast.md" end + def check_sourceforge_appcast + return if cask.version.latest? + return unless cask.url.to_s =~ %r{sourceforge.net/(\S+)} + + add_warning "Cask hosted on SourceForge, please add an appcast. See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/appcast.md" + end + def check_url return unless cask.url check_download_url_format diff --git a/Library/Homebrew/test/cask/audit_spec.rb b/Library/Homebrew/test/cask/audit_spec.rb index 7ec1675a97..e6cef82072 100644 --- a/Library/Homebrew/test/cask/audit_spec.rb +++ b/Library/Homebrew/test/cask/audit_spec.rb @@ -460,6 +460,28 @@ describe Hbc::Audit, :cask do end end + describe "SourceForge appcast check" do + let(:error_msg) { /Cask hosted on SourceForge/ } + + context "when the Cask is not hosted on SourceForge" do + let(:cask_token) { "basic-cask" } + + it { is_expected.not_to warn_with(error_msg) } + end + + context "when the Cask is hosted on SourceForge and has an appcast" do + let(:cask_token) { "sourceforge-with-appcast" } + + it { is_expected.not_to warn_with(error_msg) } + end + + context "when the Cask is hosted on SourceForge and does not have an appcast" do + let(:cask_token) { "sourceforge-correct-url-format" } + + it { is_expected.to warn_with(error_msg) } + end + end + describe "latest with appcast checks" do let(:error_msg) { "Casks with an appcast should not use version :latest" } diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-with-appcast.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-with-appcast.rb new file mode 100644 index 0000000000..fd4a388bcb --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/sourceforge-with-appcast.rb @@ -0,0 +1,8 @@ +cask 'sourceforge-with-appcast' do + version '1.2.3' + + url 'https://downloads.sourceforge.net/something/Something-1.2.3.dmg' + appcast 'https://sourceforge.net/projects/something/rss', + checkpoint: '407fb59baa4b9eb7651d9243b89c30b7481590947ef78bd5a4c24f5810f56531' + homepage 'https://sourceforge.net/projects/something/' +end