Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate appcast. #15085

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 17 additions & 62 deletions Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class Audit

attr_reader :cask, :download

attr_predicate :appcast?, :new_cask?, :strict?, :signing?, :online?, :token_conflicts?
attr_predicate :new_cask?, :strict?, :signing?, :online?, :token_conflicts?

def initialize(
cask,
appcast: nil, download: nil, quarantine: nil,
download: nil, quarantine: nil,
token_conflicts: nil, online: nil, strict: nil, signing: nil,
new_cask: nil, only: [], except: []
)
Expand All @@ -34,15 +34,10 @@ def initialize(
signing = new_cask if signing.nil?
token_conflicts = new_cask if token_conflicts.nil?

# `online` implies `appcast` and `download`
appcast = online if appcast.nil?
download = online if download.nil?

# `signing` implies `download`
download = signing if download.nil?
# `online` and `signing` imply `download`
download = online || signing if download.nil?

@cask = cask
@appcast = appcast
@download = Download.new(cask, quarantine: quarantine) if download
@online = online
@strict = strict
Expand Down Expand Up @@ -292,22 +287,15 @@ def audit_sha256_invalid
end

sig { void }
def audit_appcast_and_livecheck
def audit_appcast
return unless cask.appcast

if cask.livecheckable?
add_error "Cask has a `livecheck`, the `appcast` should be removed."
elsif new_cask?
add_error "New casks should use a `livecheck` instead of an `appcast`."
end
add_error "`appcast` should be replaced with a `livecheck`."
end

sig { void }
def audit_latest_with_appcast_or_livecheck
def audit_latest_with_livecheck
return unless cask.version.latest?

add_error "Casks with an `appcast` should not use `version :latest`." if cask.appcast

return unless cask.livecheckable?
return if cask.livecheck.skip?

Expand All @@ -326,8 +314,10 @@ def audit_latest_with_auto_updates

sig { params(livecheck_result: T.any(NilClass, T::Boolean, Symbol)).void }
def audit_hosting_with_livecheck(livecheck_result: audit_livecheck_version)
return if cask.discontinued? || cask.version.latest?
return if block_url_offline? || cask.appcast || cask.livecheckable?
return if cask.discontinued?
return if cask.version.latest?
return if block_url_offline?
return if cask.livecheckable?
return if livecheck_result == :auto_detected

add_livecheck = "please add a livecheck. See #{Formatter.url(LIVECHECK_REFERENCE_URL)}"
Expand Down Expand Up @@ -478,7 +468,7 @@ def audit_download
end

sig { void }
def audit_appcast_unneeded_long_version
def audit_livecheck_unneeded_long_version
return unless cask.livecheck.strategy == :sparkle
return unless cask.version.csv.second
return if cask.url.to_s.include? cask.version.csv.second
Expand Down Expand Up @@ -561,7 +551,7 @@ def audit_signing

sig { returns(T.any(NilClass, T::Boolean, Symbol)) }
def audit_livecheck_version
return unless appcast?
return unless online?

referenced_cask, = Homebrew::Livecheck.resolve_livecheck_reference(cask)

Expand All @@ -581,16 +571,8 @@ def audit_livecheck_version
cask,
referenced_formula_or_cask: referenced_cask,
)&.fetch(:latest)
if cask.version.to_s == latest_version.to_s
if cask.appcast
add_error "Version '#{latest_version}' was automatically detected by livecheck; " \
"the appcast should be removed."
end

return :auto_detected
end

return :appcast if cask.appcast && !cask.livecheckable?
return :auto_detected if cask.version.to_s == latest_version.to_s

add_error "Version '#{cask.version}' differs from '#{latest_version}' retrieved by livecheck."

Expand Down Expand Up @@ -643,33 +625,6 @@ def audit_livecheck_min_os
"and the cask defined #{min_os_symbol}"
end

sig { void }
def audit_appcast_contains_version
return unless appcast?
return if cask.appcast.to_s.empty?
return if cask.appcast.must_contain == :no_check

appcast_url = cask.appcast.to_s
begin
details = curl_http_content_headers_and_checksum(appcast_url, user_agent: HOMEBREW_USER_AGENT_FAKE_SAFARI)
appcast_contents = details[:file]
rescue
add_error "appcast at URL '#{Formatter.url(appcast_url)}' offline or looping"
return
end

version_stanza = cask.version.to_s
adjusted_version_stanza = cask.appcast.must_contain.presence || version_stanza.match(/^[[:alnum:].]+/)[0]
return if appcast_contents.blank?
return if appcast_contents.include?(adjusted_version_stanza)

add_error <<~EOS.chomp
appcast at URL '#{Formatter.url(appcast_url)}' does not contain \
the version number '#{adjusted_version_stanza}':
#{appcast_contents}
EOS
end

sig { void }
def audit_github_prerelease_version
return if cask.tap == "homebrew/cask-versions"
Expand Down Expand Up @@ -808,8 +763,9 @@ def audit_https_availability
user_agents: [cask.url.user_agent], referer: cask.url&.referer)
end

if cask.appcast && appcast?
validate_url_for_https_availability(cask.appcast, "appcast URL", cask.token, cask.tap, check_content: true)
if cask.livecheckable? && !cask.livecheck.url.is_a?(Symbol)
validate_url_for_https_availability(cask.livecheck.url, "livecheck URL", cask.token, cask.tap,
check_content: true)
end

return unless cask.homepage
Expand Down Expand Up @@ -841,7 +797,6 @@ def get_repo_data(regex)

_, user, repo = *regex.match(cask.url.to_s)
_, user, repo = *regex.match(cask.homepage) unless user
_, user, repo = *regex.match(cask.appcast.to_s) unless user
return if !user || !repo

repo.gsub!(/.git$/, "")
Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/cask/auditor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def self.audit(cask, **options)
def initialize(
cask,
audit_download: nil,
audit_appcast: nil,
audit_online: nil,
audit_strict: nil,
audit_signing: nil,
Expand All @@ -33,7 +32,6 @@ def initialize(
)
@cask = cask
@audit_download = audit_download
@audit_appcast = audit_appcast
@audit_online = audit_online
@audit_new_cask = audit_new_cask
@audit_strict = audit_strict
Expand Down Expand Up @@ -120,7 +118,6 @@ def audit_languages(languages)
def audit_cask_instance(cask)
audit = Audit.new(
cask,
appcast: @audit_appcast,
online: @audit_online,
strict: @audit_strict,
signing: @audit_signing,
Expand Down
6 changes: 2 additions & 4 deletions Library/Homebrew/cask/cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def self.parser
switch "--[no-]download",
description: "Audit the downloaded file"
switch "--[no-]appcast",
description: "Audit the appcast"
description: "Audit the appcast",
replacement: false
switch "--[no-]token-conflicts",
description: "Audit for token conflicts"
switch "--[no-]signing",
Expand Down Expand Up @@ -49,7 +50,6 @@ def run
results = self.class.audit_casks(
*casks,
download: args.download?,
appcast: args.appcast?,
online: args.online?,
strict: args.strict?,
signing: args.signing?,
Expand All @@ -73,7 +73,6 @@ def run
def self.audit_casks(
*casks,
download:,
appcast:,
online:,
strict:,
signing:,
Expand All @@ -89,7 +88,6 @@ def self.audit_casks(
)
options = {
audit_download: download,
audit_appcast: appcast,
audit_online: online,
audit_strict: strict,
audit_signing: signing,
Expand Down
7 changes: 5 additions & 2 deletions Library/Homebrew/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
require "cask/caskroom"
require "cask/exceptions"

require "cask/dsl/appcast"
require "cask/dsl/base"
require "cask/dsl/caveats"
require "cask/dsl/conflicts_with"
Expand Down Expand Up @@ -211,7 +210,11 @@ def url(*args, **options, &block)

# @api public
def appcast(*args, **kwargs)
set_unique_stanza(:appcast, args.empty? && kwargs.empty?) { DSL::Appcast.new(*args, **kwargs) }
set_unique_stanza(:appcast, args.empty? && kwargs.empty?) do
# TODO: Remove the remaining audit for `appcast` usage when enabling this deprecation.
# odeprecated "the `appcast` stanza", "the `livecheck` stanza"
true
end
end

# @api public
Expand Down
27 changes: 0 additions & 27 deletions Library/Homebrew/cask/dsl/appcast.rb

This file was deleted.

4 changes: 2 additions & 2 deletions Library/Homebrew/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def initialize(&block)
end

def switch(*names, description: nil, replacement: nil, env: nil, depends_on: nil,
method: :on, hidden: false)
method: :on, hidden: false, disable: false)
global_switch = names.first.is_a?(Symbol)
return if global_switch

Expand All @@ -167,7 +167,7 @@ def switch(*names, description: nil, replacement: nil, env: nil, depends_on: nil
description += " (disabled#{"; replaced by #{replacement}" if replacement.present?})"
end
@parser.public_send(method, *names, *wrap_option_desc(description)) do |value|
odisabled "the `#{names.first}` switch", replacement unless replacement.nil?
odeprecated "the `#{names.first}` switch", replacement, disable: disable if !replacement.nil? || disable
value = true if names.none? { |name| name.start_with?("--[no-]") }

set_switch(*names, value: value, from: :args)
Expand Down
6 changes: 4 additions & 2 deletions Library/Homebrew/cmd/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def tap_args
switch "--full",
description: "Convert a shallow clone to a full clone without untapping. Taps are only cloned as " \
"shallow clones if `--shallow` was originally passed.",
replacement: false
replacement: false,
disable: true
switch "--shallow",
description: "Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration.",
replacement: false
replacement: false,
disable: true
switch "--[no-]force-auto-update",
description: "Auto-update tap even if it is not hosted on GitHub. By default, only taps " \
"hosted on GitHub are auto-updated (for performance reasons)."
Expand Down
5 changes: 2 additions & 3 deletions Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def self.audit_args
"for Homebrew. This should be used when creating new formula and implies " \
"`--strict` and `--online`."
switch "--[no-]appcast",
description: "Audit the appcast."
description: "Audit the appcast.",
replacement: false
switch "--[no-]signing",
description: "Audit for signed apps, which are required on ARM"
switch "--token-conflicts",
Expand Down Expand Up @@ -246,8 +247,6 @@ def self.audit
Cask::Cmd::Audit.audit_casks(
*audit_casks,
download: nil,
# No need for `|| nil` for `--[no-]appcast` because boolean switches are already `nil` if not passed
appcast: args.appcast?,
# No need for `|| nil` for `--[no-]signing` because boolean switches are already `nil` if not passed
signing: args.signing?,
online: args.online? || nil,
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/livecheck/livecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,6 @@ def checkable_urls(package_or_resource)
urls << package_or_resource.head.url if package_or_resource.head
urls << package_or_resource.homepage if package_or_resource.homepage
when Cask::Cask
urls << package_or_resource.appcast.to_s if package_or_resource.appcast
urls << package_or_resource.url.to_s if package_or_resource.url
urls << package_or_resource.homepage if package_or_resource.homepage
when Resource
Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/sorbet/rbi/parlour.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ end

module Cask
class Audit
sig { returns(T::Boolean) }
def appcast?; end

sig { returns(T::Boolean) }
def new_cask?; end

Expand Down