From ef58225749cc9688b86293861f7e087a0edafc5e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 30 Oct 2016 13:49:55 -0400 Subject: [PATCH 1/2] audit: check the version does not decrease. This will prevent brew upgrade from working correctly. --- Library/Homebrew/dev-cmd/audit.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1fa5837059..3cebfc2256 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -655,10 +655,11 @@ class FormulaAuditor return unless formula.tap.git? # git log is required fv = FormulaVersions.new(formula, max_depth: 10) - attributes = [:revision, :version_scheme] + no_decrease_attributes = [:revision, :version_scheme] + attributes = no_decrease_attributes + [:version] attributes_map = fv.version_attributes_map(attributes, "origin/master") - attributes.each do |attribute| + no_decrease_attributes.each do |attribute| attributes_for_version = attributes_map[attribute][formula.version] next if attributes_for_version.empty? if formula.send(attribute) < attributes_for_version.max @@ -666,11 +667,14 @@ class FormulaAuditor end end - revision_map = attributes_map[:revision] + versions = attributes_map[:version].values.flatten + if formula.version < versions.max + problem "version should not decrease" + end return if formula.revision.zero? - if formula.stable + revision_map = attributes_map[:revision] if revision_map[formula.stable.version].empty? # check stable spec problem "'revision #{formula.revision}' should be removed" end From 127461d8792ff9a638c86bfaaedbed3cda2d38db Mon Sep 17 00:00:00 2001 From: Baptiste Fontaine Date: Sun, 30 Oct 2016 10:38:37 +0100 Subject: [PATCH 2/2] audit: don't check new formulae revision/versions. --- Library/Homebrew/dev-cmd/audit.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 3cebfc2256..e83cf1b8cf 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -653,6 +653,7 @@ class FormulaAuditor def audit_revision_and_version_scheme return unless formula.tap # skip formula not from core or any taps return unless formula.tap.git? # git log is required + return if @new_formula fv = FormulaVersions.new(formula, max_depth: 10) no_decrease_attributes = [:revision, :version_scheme] @@ -668,7 +669,7 @@ class FormulaAuditor end versions = attributes_map[:version].values.flatten - if formula.version < versions.max + if !versions.empty? && formula.version < versions.max problem "version should not decrease" end