versions: split version_for_sha and use yield.
This commit is contained in:
parent
7531dfc219
commit
4702774616
@ -81,6 +81,10 @@ class Formula
|
|||||||
ArgumentError, FormulaSpecificationError]
|
ArgumentError, FormulaSpecificationError]
|
||||||
|
|
||||||
def version_for_sha sha
|
def version_for_sha sha
|
||||||
|
formula_for_sha(sha) {|f| f.version }
|
||||||
|
end
|
||||||
|
|
||||||
|
def formula_for_sha sha, &block
|
||||||
mktemp do
|
mktemp do
|
||||||
path = Pathname.new(Pathname.pwd+"#{name}.rb")
|
path = Pathname.new(Pathname.pwd+"#{name}.rb")
|
||||||
path.write text_from_sha(sha)
|
path.write text_from_sha(sha)
|
||||||
@ -88,7 +92,7 @@ class Formula
|
|||||||
# Unload the class so Formula#version returns the correct value
|
# Unload the class so Formula#version returns the correct value
|
||||||
begin
|
begin
|
||||||
Formulary.unload_formula name
|
Formulary.unload_formula name
|
||||||
nostdout { Formula.factory(path.to_s).version }
|
nostdout { yield Formula.factory(path.to_s) }
|
||||||
rescue *IGNORED_EXCEPTIONS => e
|
rescue *IGNORED_EXCEPTIONS => e
|
||||||
# We rescue these so that we can skip bad versions and
|
# We rescue these so that we can skip bad versions and
|
||||||
# continue walking the history
|
# continue walking the history
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user