formula_versions: add version_attributes_map.
This allows querying multiple attributes in the same way as `revision_map` did but without duplicating code or repeatedly traversing history.
This commit is contained in:
parent
cc2a90ec8d
commit
55ba22e296
@ -627,7 +627,7 @@ class FormulaAuditor
|
|||||||
return unless formula.tap.git? # git log is required
|
return unless formula.tap.git? # git log is required
|
||||||
|
|
||||||
fv = FormulaVersions.new(formula, :max_depth => 10)
|
fv = FormulaVersions.new(formula, :max_depth => 10)
|
||||||
revision_map = fv.revision_map("origin/master")
|
revision_map = fv.version_attributes_map([:revision], "origin/master")
|
||||||
revisions = revision_map[formula.version]
|
revisions = revision_map[formula.version]
|
||||||
if !revisions.empty?
|
if !revisions.empty?
|
||||||
problem "revision should not decrease" if formula.revision < revisions.max
|
problem "revision should not decrease" if formula.revision < revisions.max
|
||||||
|
|||||||
@ -60,14 +60,22 @@ class FormulaVersions
|
|||||||
map
|
map
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision_map(branch)
|
def version_attributes_map(attributes, branch)
|
||||||
map = Hash.new { |h, k| h[k] = [] }
|
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|
|
rev_list(branch) do |rev|
|
||||||
formula_at_revision(rev) do |f|
|
formula_at_revision(rev) do |f|
|
||||||
map[f.stable.version] << f.revision if f.stable
|
attributes.each do |attribute|
|
||||||
map[f.devel.version] << f.revision if f.devel
|
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
|
end
|
||||||
map
|
end
|
||||||
|
attributes_map
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user