Allow brew versions to work with underspecified formulae
This commit is contained in:
parent
62db042277
commit
9b5cb6cfb6
@ -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?
|
||||
|
||||
@ -33,6 +33,9 @@ class FormulaValidationError < StandardError
|
||||
end
|
||||
end
|
||||
|
||||
class FormulaSpecificationError < StandardError
|
||||
end
|
||||
|
||||
class FormulaUnavailableError < RuntimeError
|
||||
attr_reader :name
|
||||
attr_accessor :dependent
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user