From ce2d946a7cd11a69ea1631579bf7df0e738adf0f Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Wed, 20 Oct 2021 20:14:51 +0100 Subject: [PATCH] formula_auditor: add audit for formulae with synced versions --- Library/Homebrew/formula_auditor.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index d558ce4494..70526559ee 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -118,6 +118,31 @@ module Homebrew @aliases ||= Formula.aliases + Formula.tap_aliases end + SYNCED_VERSIONS_FORMULAE_FILE = "synced_versions_formulae.json" + + def audit_synced_versions_formulae + synced_versions_formulae_file = formula.tap.path/SYNCED_VERSIONS_FORMULAE_FILE + return unless synced_versions_formulae_file.file? + + name = formula.name + version = formula.version + + synced_versions_formulae = JSON.parse(synced_versions_formulae_file.read) + synced_versions_formulae.each do |synced_version_formulae| + next unless synced_version_formulae.include? name + + synced_version_formulae.each do |synced_formula| + next if synced_formula == name + + if (synced_version = Formulary.factory(synced_formula).version) != version + problem "Version of `#{synced_formula}` (#{synced_version}) should match version of `#{name}` (#{version})" + end + end + + break + end + end + def audit_formula_name name = formula.name