diff options
| author | Jack Nagel | 2013-04-27 14:44:48 -0500 | 
|---|---|---|
| committer | Jack Nagel | 2013-04-27 14:44:48 -0500 | 
| commit | 03a4ecfbcaf758f5c2c1b06fcbf332c44a6e1d68 (patch) | |
| tree | 3b2542a8c99f85a81c15a4a2aca6af9229124f7a | |
| parent | 17471361b4592ddc21ac920e234e9d6443ce3838 (diff) | |
| download | homebrew-03a4ecfbcaf758f5c2c1b06fcbf332c44a6e1d68.tar.bz2 | |
Allow `brew versions` to work with underspecified formulae
| -rw-r--r-- | Library/Homebrew/cmd/versions.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/exceptions.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/formula.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula_validation.rb | 4 | 
4 files changed, 10 insertions, 4 deletions
| diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index 205f4467e..45968100f 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -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? diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index b5299c038..4f1fafdce 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -33,6 +33,9 @@ class FormulaValidationError < StandardError    end  end +class FormulaSpecificationError < StandardError +end +  class FormulaUnavailableError < RuntimeError    attr_reader :name    attr_accessor :dependent diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1eb95c273..88d4c9af9 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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 diff --git a/Library/Homebrew/test/test_formula_validation.rb b/Library/Homebrew/test/test_formula_validation.rb index 9afdc278c..c87f842a1 100644 --- a/Library/Homebrew/test/test_formula_validation.rb +++ b/Library/Homebrew/test/test_formula_validation.rb @@ -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 | 
