diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index 3c9ed0386a..8c700f42e8 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -1,4 +1,5 @@ require "formula" +require "formula_versions" require "utils" require "extend/ENV" require "formula_cellar_checks" @@ -579,6 +580,19 @@ class FormulaAuditor end end + def audit_revision + return unless formula.tap # skip formula not from core or any taps + return unless formula.tap.git? # git log is required + + fv = FormulaVersions.new(formula) + revision_map = fv.revision_map("origin/master") + if (revisions = revision_map[formula.version]).any? + problem "revision should not decrease" if formula.revision < revisions.max + else + problem "revision should be removed" unless formula.revision == 0 + end + end + def audit_legacy_patches return unless formula.respond_to?(:patches) legacy_patches = Patch.normalize_legacy_patches(formula.patches).grep(LegacyPatch) @@ -932,6 +946,7 @@ class FormulaAuditor audit_formula_name audit_class audit_specs + audit_revision audit_desc audit_homepage audit_bottle_spec diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index 34416dca49..d83a0aae65 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -54,4 +54,14 @@ class FormulaVersions end map end + + def revision_map(branch) + map = Hash.new { |h, k| h[k] = [] } + rev_list(branch) do |rev| + formula_at_revision(rev) do |f| + map[f.version] << f.revision + end + end + map + end end