From 50d53330bc36cda2352a23061168339eea4a6f36 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sat, 13 Jan 2024 11:56:25 +0200 Subject: [PATCH] feat: add audit for wayback machine URLs --- Library/Homebrew/formula_auditor.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index 7ac8a334a0cdf1..79692468a628a2 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -602,6 +602,28 @@ def audit_eol problem "Product is EOL since #{metadata["eol"]}, #{see_url}" if Date.parse(metadata["eol"]) <= Date.today end + def audit_wayback_url + return unless @strict + return unless @core_tap + return if formula.deprecated? || formula.disabled? + + regex = %r{^https?://web\.archive\.org} + problem_prefix = "Formula with a Internet Archive Wayback Machine" + if regex.match?(formula.stable.url) + problem "#{problem_prefix} `url` should be deprecated with `:repo_removed`" + end + + if regex.match?(formula.homepage) + problem "#{problem_prefix} `homepage` should find an alternative `homepage` or be deprecated." + end + + return unless formula.head + + return unless regex.match?(formula.head.url) + + problem "Remove Internet Archive Wayback Machine `head` URL" + end + def audit_github_repository_archived return if formula.deprecated? || formula.disabled?