diff options
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/dev-cmd/audit.rb | 37 | ||||
| -rw-r--r-- | Library/Homebrew/formula_versions.rb | 15 | 
2 files changed, 37 insertions, 15 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 568051b43..9024cf50c 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -662,26 +662,39 @@ class FormulaAuditor      return if @new_formula      fv = FormulaVersions.new(formula, max_depth: 10) -    no_decrease_attributes = [:revision, :version_scheme] -    attributes = no_decrease_attributes + [:version] +    attributes = [:revision, :version_scheme] +      attributes_map = fv.version_attributes_map(attributes, "origin/master") -    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 -        problem "#{attribute} should not decrease" +    [:stable, :devel].each do |spec| +      attributes.each do |attribute| +        spec_attribute_map = attributes_map[attribute][spec] +        next if spec_attribute_map.nil? || spec_attribute_map.empty? + +        attributes_for_version = spec_attribute_map[formula.version] +        next if attributes_for_version.nil? || attributes_for_version.empty? + +        if formula.send(attribute) < attributes_for_version.max +          problem "#{spec} #{attribute} should not decrease" +        end        end -    end -    versions = attributes_map[:version].values.flatten -    if !versions.empty? && formula.version < versions.max -      problem "version should not decrease" +      spec_version_scheme_map = attributes_map[:version_scheme][spec] +      next if spec_version_scheme_map.nil? || spec_version_scheme_map.empty? + +      max_version_scheme = spec_version_scheme_map.values.flatten.max +      max_version = spec_version_scheme_map.select do |_, version_scheme| +        version_scheme.first == max_version_scheme +      end.keys.max + +      if max_version && formula.version < max_version +        problem "#{spec} version should not decrease" +      end      end      return if formula.revision.zero?      if formula.stable -      revision_map = attributes_map[:revision] +      revision_map = attributes_map[:revision][:stable]        if revision_map[formula.stable.version].empty? # check stable spec          problem "'revision #{formula.revision}' should be removed"        end diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index d9a082399..f17ceefd5 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -61,19 +61,28 @@ class FormulaVersions    def version_attributes_map(attributes, branch)      attributes_map = {}      return attributes_map if attributes.empty? +      attributes.each do |attribute| -      attributes_map[attribute] = Hash.new { |h, k| h[k] = [] } +      attributes_map[attribute] ||= {}      end      rev_list(branch) do |rev|        formula_at_revision(rev) do |f|          attributes.each do |attribute|            map = attributes_map[attribute] -          map[f.stable.version] << f.send(attribute) if f.stable -          map[f.devel.version] << f.send(attribute) if f.devel +          if f.stable +            map[:stable] ||= {} +            map[:stable][f.stable.version] ||= [] +            map[:stable][f.stable.version] << f.send(attribute) +          end +          next unless f.devel +          map[:devel] ||= {} +          map[:stable][f.devel.version] ||= [] +          map[:devel][f.devel.version] << f.send(attribute)          end        end      end +      attributes_map    end  end  | 
