From b12498159bce95aed7b03332cfe52dfec7a6451c Mon Sep 17 00:00:00 2001 From: commitay Date: Fri, 15 Jun 2018 17:01:27 +1000 Subject: [PATCH] cask audit: check for devmate and hockeyapp appcasts --- Library/Homebrew/cask/lib/hbc/audit.rb | 25 ++++++------ Library/Homebrew/test/cask/audit_spec.rb | 40 +++++++++++++------ .../cask/Casks/devmate-with-appcast.rb | 12 ++++++ .../cask/Casks/devmate-without-appcast.rb | 11 +++++ .../cask/Casks/hockeyapp-with-appcast.rb | 12 ++++++ .../cask/Casks/hockeyapp-without-appcast.rb | 11 +++++ 6 files changed, 85 insertions(+), 26 deletions(-) create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/devmate-with-appcast.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/devmate-without-appcast.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/hockeyapp-with-appcast.rb create mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/hockeyapp-without-appcast.rb diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index be8c95049f..db56cff872 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -201,21 +201,20 @@ module Hbc 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_appcast = "please add an appcast. See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/appcast.md" - add_warning "Download 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 "Download is hosted on SourceForge, please add an appcast. See https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/appcast.md" + case cask.url.to_s + when %r{github.com/([^/]+)/([^/]+)/releases/download/(\S+)} + add_warning "Download uses GitHub releases, #{add_appcast}" + when %r{sourceforge.net/(\S+)} + return if cask.version.latest? + add_warning "Download is hosted on SourceForge, #{add_appcast}" + when %r{dl.devmate.com/(\S+)} + add_warning "Download is hosted on DevMate, #{add_appcast}" + when %r{rink.hockeyapp.net/(\S+)} + add_warning "Download is hosted on HockeyApp, #{add_appcast}" + end end def check_url diff --git a/Library/Homebrew/test/cask/audit_spec.rb b/Library/Homebrew/test/cask/audit_spec.rb index 37d4f95abc..82487982a9 100644 --- a/Library/Homebrew/test/cask/audit_spec.rb +++ b/Library/Homebrew/test/cask/audit_spec.rb @@ -333,10 +333,10 @@ describe Hbc::Audit, :cask do end end - describe "GitHub releases appcast check" do - let(:appcast_warning) { /Download uses GitHub releases/ } + describe "hosting with appcast checks" do + let(:appcast_warning) { /please add an appcast/ } - context "when the download does not use GitHub releases" do + context "when the download does not use hosting with an appcast" do let(:cask_token) { "basic-cask" } it { is_expected.not_to warn_with(appcast_warning) } @@ -353,16 +353,6 @@ describe Hbc::Audit, :cask do it { is_expected.to warn_with(appcast_warning) } end - end - - describe "SourceForge appcast check" do - let(:appcast_warning) { /Download is hosted on SourceForge/ } - - context "when the download is not hosted on SourceForge" do - let(:cask_token) { "basic-cask" } - - it { is_expected.not_to warn_with(appcast_warning) } - end context "when the download is hosted on SourceForge and has an appcast" do let(:cask_token) { "sourceforge-with-appcast" } @@ -375,6 +365,30 @@ describe Hbc::Audit, :cask do it { is_expected.to warn_with(appcast_warning) } end + + context "when the download is hosted on DevMate and has an appcast" do + let(:cask_token) { "devmate-with-appcast" } + + it { is_expected.not_to warn_with(appcast_warning) } + end + + context "when the download is hosted on DevMate and does not have an appcast" do + let(:cask_token) { "devmate-without-appcast" } + + it { is_expected.to warn_with(appcast_warning) } + end + + context "when the download is hosted on HockeyApp and has an appcast" do + let(:cask_token) { "hockeyapp-with-appcast" } + + it { is_expected.not_to warn_with(appcast_warning) } + end + + context "when the download is hosted on HockeyApp and does not have an appcast" do + let(:cask_token) { "hockeyapp-without-appcast" } + + it { is_expected.to warn_with(appcast_warning) } + end end describe "latest with appcast checks" do diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/devmate-with-appcast.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/devmate-with-appcast.rb new file mode 100644 index 0000000000..d6c48d3411 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/devmate-with-appcast.rb @@ -0,0 +1,12 @@ +cask 'devmate-with-appcast' do + version '1.0' + sha256 'a69e7357bea014f4c14ac9699274f559086844ffa46563c4619bf1addfd72ad9' + + # dl.devmate.com/com.my.fancyapp was verified as official when first introduced to the cask + url "https://dl.devmate.com/com.my.fancyapp/app_#{version}.zip" + appcast 'https://updates.devmate.com/com.my.fancyapp.app.xml' + name 'DevMate' + homepage 'http://www.example.com/' + + app 'DevMate.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/devmate-without-appcast.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/devmate-without-appcast.rb new file mode 100644 index 0000000000..a04d20634c --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/devmate-without-appcast.rb @@ -0,0 +1,11 @@ +cask 'devmate-without-appcast' do + version '1.0' + sha256 'a69e7357bea014f4c14ac9699274f559086844ffa46563c4619bf1addfd72ad9' + + # dl.devmate.com/com.my.fancyapp was verified as official when first introduced to the cask + url "https://dl.devmate.com/com.my.fancyapp/app_#{version}.zip" + name 'DevMate' + homepage 'http://www.example.com/' + + app 'DevMate.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/hockeyapp-with-appcast.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/hockeyapp-with-appcast.rb new file mode 100644 index 0000000000..6a9f9c5f84 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/hockeyapp-with-appcast.rb @@ -0,0 +1,12 @@ +cask 'hockeyapp-with-appcast' do + version '1.0,123' + sha256 'a69e7357bea014f4c14ac9699274f559086844ffa46563c4619bf1addfd72ad9' + + # rink.hockeyapp.net/api/2/apps/67503a7926431872c4b6c1549f5bd6b1 was verified as official when first introduced to the cask + url "https://rink.hockeyapp.net/api/2/apps/67503a7926431872c4b6c1549f5bd6b1/app_versions/#{version.after_comma}?format=zip" + appcast 'https://rink.hockeyapp.net/api/2/apps/67503a7926431872c4b6c1549f5bd6b1' + name 'HockeyApp' + homepage 'http://www.example.com/' + + app 'HockeyApp.app' +end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/hockeyapp-without-appcast.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/hockeyapp-without-appcast.rb new file mode 100644 index 0000000000..86b853bbd5 --- /dev/null +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/hockeyapp-without-appcast.rb @@ -0,0 +1,11 @@ +cask 'hockeyapp-without-appcast' do + version '1.0,123' + sha256 'a69e7357bea014f4c14ac9699274f559086844ffa46563c4619bf1addfd72ad9' + + # rink.hockeyapp.net/api/2/apps/67503a7926431872c4b6c1549f5bd6b1 was verified as official when first introduced to the cask + url "https://rink.hockeyapp.net/api/2/apps/67503a7926431872c4b6c1549f5bd6b1/app_versions/#{version.after_comma}?format=zip" + name 'HockeyApp' + homepage 'http://www.example.com/' + + app 'HockeyApp.app' +end