Skip to content
Snippets Groups Projects
Commit b1249815 authored by commitay's avatar commitay
Browse files

cask audit: check for devmate and hockeyapp appcasts

parent 0d33aba0
No related branches found
No related tags found
No related merge requests found
......@@ -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_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"
add_appcast = "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
......
......@@ -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,25 +353,39 @@ 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 hosted on SourceForge and has an appcast" do
let(:cask_token) { "sourceforge-with-appcast" }
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 does not have an appcast" do
let(:cask_token) { "sourceforge-correct-url-format" }
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 SourceForge and has an appcast" do
let(:cask_token) { "sourceforge-with-appcast" }
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 SourceForge and does not have an appcast" do
let(:cask_token) { "sourceforge-correct-url-format" }
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
......
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
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
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment