Allow brew versions to work with underspecified formulae

This commit is contained in:
Jack Nagel 2013-04-27 14:44:48 -05:00
parent 62db042277
commit 9b5cb6cfb6
4 changed files with 10 additions and 4 deletions

View File

@ -77,6 +77,9 @@ class Formula
rev_list.find{ |sha| version == version_for_sha(sha) }
end
IGNORED_EXCEPTIONS = [SyntaxError, TypeError, NameError,
ArgumentError, FormulaSpecificationError]
def version_for_sha sha
mktemp do
path = Pathname.new(Pathname.pwd+"#{name}.rb")
@ -86,7 +89,7 @@ class Formula
begin
Object.send(:remove_const, Formula.class_s(name))
nostdout { Formula.factory(path).version }
rescue SyntaxError, TypeError, NameError, ArgumentError => e
rescue *IGNORED_EXCEPTIONS => e
# We rescue these so that we can skip bad versions and
# continue walking the history
ohai "#{e} in #{name} at revision #{sha}", e.backtrace if ARGV.debug?

View File

@ -33,6 +33,9 @@ class FormulaValidationError < StandardError
end
end
class FormulaSpecificationError < StandardError
end
class FormulaUnavailableError < RuntimeError
attr_reader :name
attr_accessor :dependent

View File

@ -77,7 +77,7 @@ class Formula
when @devel && @stable.nil? then @devel # devel-only
when @head && @stable.nil? then @head # head-only
else
raise "Formulae require at least a URL"
raise FormulaSpecificationError, "formulae require at least a URL"
end
end

View File

@ -78,7 +78,7 @@ class FormulaValidationTests < Test::Unit::TestCase
end
def test_empty_formula_invalid
e = assert_raises(RuntimeError) { formula {} }
assert_equal "Formulae require at least a URL", e.message
e = assert_raises(FormulaSpecificationError) { formula {} }
assert_equal "formulae require at least a URL", e.message
end
end