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) }
|
rev_list.find{ |sha| version == version_for_sha(sha) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
IGNORED_EXCEPTIONS = [SyntaxError, TypeError, NameError,
|
||||||
|
ArgumentError, FormulaSpecificationError]
|
||||||
|
|
||||||
def version_for_sha sha
|
def version_for_sha sha
|
||||||
mktemp do
|
mktemp do
|
||||||
path = Pathname.new(Pathname.pwd+"#{name}.rb")
|
path = Pathname.new(Pathname.pwd+"#{name}.rb")
|
||||||
@ -86,7 +89,7 @@ class Formula
|
|||||||
begin
|
begin
|
||||||
Object.send(:remove_const, Formula.class_s(name))
|
Object.send(:remove_const, Formula.class_s(name))
|
||||||
nostdout { Formula.factory(path).version }
|
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
|
# We rescue these so that we can skip bad versions and
|
||||||
# continue walking the history
|
# continue walking the history
|
||||||
ohai "#{e} in #{name} at revision #{sha}", e.backtrace if ARGV.debug?
|
ohai "#{e} in #{name} at revision #{sha}", e.backtrace if ARGV.debug?
|
||||||
|
|||||||
@ -33,6 +33,9 @@ class FormulaValidationError < StandardError
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class FormulaSpecificationError < StandardError
|
||||||
|
end
|
||||||
|
|
||||||
class FormulaUnavailableError < RuntimeError
|
class FormulaUnavailableError < RuntimeError
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
attr_accessor :dependent
|
attr_accessor :dependent
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class Formula
|
|||||||
when @devel && @stable.nil? then @devel # devel-only
|
when @devel && @stable.nil? then @devel # devel-only
|
||||||
when @head && @stable.nil? then @head # head-only
|
when @head && @stable.nil? then @head # head-only
|
||||||
else
|
else
|
||||||
raise "Formulae require at least a URL"
|
raise FormulaSpecificationError, "formulae require at least a URL"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -78,7 +78,7 @@ class FormulaValidationTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_empty_formula_invalid
|
def test_empty_formula_invalid
|
||||||
e = assert_raises(RuntimeError) { formula {} }
|
e = assert_raises(FormulaSpecificationError) { formula {} }
|
||||||
assert_equal "Formulae require at least a URL", e.message
|
assert_equal "formulae require at least a URL", e.message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user