diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 09bde070a7..7e2297becc 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -492,7 +492,15 @@ module Cask metadata = SharedAudits.github_repo_data(user, repo) return if metadata.nil? - add_error "GitHub repo is archived" if metadata["archived"] + return unless metadata["archived"] + + message = "GitHub repo is archived" + + if cask.discontinued? + add_warning message + else + add_error message + end end def check_gitlab_repository_archived @@ -504,7 +512,15 @@ module Cask metadata = SharedAudits.gitlab_repo_data(user, repo) return if metadata.nil? - add_error "GitLab repo is archived" if metadata["archived"] + return unless metadata["archived"] + + message = "GitLab repo is archived" + + if cask.discontinued? + add_warning message + else + add_error message + end end def check_github_repository diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index a716b59277..c365852900 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -80,6 +80,7 @@ module Cask :url, :version, :appdir, + :discontinued?, *ORDINARY_ARTIFACT_CLASSES.map(&:dsl_key), *ACTIVATABLE_ARTIFACT_CLASSES.map(&:dsl_key), *ARTIFACT_BLOCK_CLASSES.flat_map { |klass| [klass.dsl_key, klass.uninstall_dsl_key] }, @@ -259,6 +260,10 @@ module Cask @caveats end + def discontinued? + @caveats&.discontinued? + end + def auto_updates(auto_updates = nil) set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates } end diff --git a/Library/Homebrew/cask/dsl/caveats.rb b/Library/Homebrew/cask/dsl/caveats.rb index d1b29565d6..9673fbc368 100644 --- a/Library/Homebrew/cask/dsl/caveats.rb +++ b/Library/Homebrew/cask/dsl/caveats.rb @@ -15,10 +15,15 @@ module Cask # # @api private class Caveats < Base + extend Predicable + + attr_predicate :discontinued? + def initialize(*args) super(*args) @built_in_caveats = {} @custom_caveats = [] + @discontinued = false end def self.caveat(name, &block) @@ -135,6 +140,7 @@ module Cask end caveat :discontinued do + @discontinued = true <<~EOS #{@cask} has been officially discontinued upstream. It may stop working correctly (or at all) in recent versions of macOS.