diff options
| author | Mike McQuaid | 2016-08-18 15:29:58 +0100 |
|---|---|---|
| committer | GitHub | 2016-08-18 15:29:58 +0100 |
| commit | 5c7c9de669025bbe4cad9829be39c5cf3b31ad25 (patch) | |
| tree | e7216154aaab5162769f87f4cc61e6ec3f71b361 /Library | |
| parent | b39eba6c5f0f6f1b19e663df52bc72b9d8518886 (diff) | |
| parent | e83da4c8e6ac70ed5fa34d73d9300ce965f8d408 (diff) | |
| download | brew-5c7c9de669025bbe4cad9829be39c5cf3b31ad25.tar.bz2 | |
Merge pull request #743 from MikeMcQuaid/version-scheme-cookbook-audit
Add Formula Cookbook entry and audit check for version_scheme
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/audit.rb | 28 | ||||
| -rw-r--r-- | Library/Homebrew/formula_versions.rb | 18 |
2 files changed, 32 insertions, 14 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb index b46f47ab5..f167e457e 100644 --- a/Library/Homebrew/cmd/audit.rb +++ b/Library/Homebrew/cmd/audit.rb @@ -209,6 +209,7 @@ class FormulaAuditor [/^ version ["'][\S\ ]+["']/, "version"], [/^ (sha1|sha256) ["'][\S\ ]+["']/, "checksum"], [/^ revision/, "revision"], + [/^ version_scheme/, "version_scheme"], [/^ head ["'][\S\ ]+["']/, "head"], [/^ stable do/, "stable block"], [/^ bottle do/, "bottle block"], @@ -622,22 +623,31 @@ class FormulaAuditor end end - def audit_revision + 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 fv = FormulaVersions.new(formula, :max_depth => 10) - revision_map = fv.revision_map("origin/master") - revisions = revision_map[formula.version] - if !revisions.empty? - problem "revision should not decrease" if formula.revision < revisions.max - elsif formula.revision != 0 + attributes = [:revision, :version_scheme] + attributes_map = fv.version_attributes_map(attributes, "origin/master") + + attributes.each do |attribute| + attributes_for_version = attributes_map[attribute][formula.version] + if !attributes_for_version.empty? + if formula.send(attribute) < attributes_for_version.max + problem "#{attribute} should not decrease" + end + end + end + + revision_map = attributes_map[:revision] + if formula.revision != 0 if formula.stable if revision_map[formula.stable.version].empty? # check stable spec - problem "revision should be removed" + problem "'revision #{formula.revision}' should be removed" end else # head/devel-only formula - problem "revision should be removed" + problem "'revision #{formula.revision}' should be removed" end end end @@ -1006,7 +1016,7 @@ class FormulaAuditor audit_formula_name audit_class audit_specs - audit_revision + audit_revision_and_version_scheme audit_desc audit_homepage audit_bottle_spec diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index 13cb8ac8c..2c5aae8f5 100644 --- a/Library/Homebrew/formula_versions.rb +++ b/Library/Homebrew/formula_versions.rb @@ -60,14 +60,22 @@ class FormulaVersions map end - def revision_map(branch) - map = Hash.new { |h, k| h[k] = [] } + 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] = [] } + end + rev_list(branch) do |rev| formula_at_revision(rev) do |f| - map[f.stable.version] << f.revision if f.stable - map[f.devel.version] << f.revision if f.devel + 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 + end end end - map + attributes_map end end |
