From 4702774616017af53d4f28bedad52e4a422c511e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 21 Sep 2013 15:14:20 +0100 Subject: [PATCH] versions: split version_for_sha and use yield. --- Library/Homebrew/cmd/versions.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index 1642220929..1dbe1a64a7 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -81,6 +81,10 @@ class Formula ArgumentError, FormulaSpecificationError] def version_for_sha sha + formula_for_sha(sha) {|f| f.version } + end + + def formula_for_sha sha, &block mktemp do path = Pathname.new(Pathname.pwd+"#{name}.rb") path.write text_from_sha(sha) @@ -88,7 +92,7 @@ class Formula # Unload the class so Formula#version returns the correct value begin Formulary.unload_formula name - nostdout { Formula.factory(path.to_s).version } + nostdout { yield Formula.factory(path.to_s) } rescue *IGNORED_EXCEPTIONS => e # We rescue these so that we can skip bad versions and # continue walking the history