From 56351558b8210d2ee9cfabf939db61dfeb9438af Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 6 Jan 2010 23:38:07 +0000 Subject: [PATCH] Check GitHub for issues relating to build failures Uses the GitHub issue search API, so it's very neat and concise. However you can get false positives, so it's not 100% useful. Still I think it is more useful than before, which was, nothing. A further issue is it depends on the ticket at GitHub using the formula's proper name. So we should ensure this as we can. Finally, it does add a possibly large delay to clean exit after a build error. We may want to fiddle with timeouts if it becomes troublesome. --- Library/Homebrew/brew.h.rb | 22 ++++++++++++++++++++++ bin/brew | 8 +++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb index 774ea80933..2ae9ed669d 100644 --- a/Library/Homebrew/brew.h.rb +++ b/Library/Homebrew/brew.h.rb @@ -212,6 +212,28 @@ rescue FormulaUnavailableError end end +def issues_for_formula name + # bit basic as depends on the issue at github having the exact name of the + # formula in it. Which for stuff like objective-caml is unlikely. So we + # really should search for aliases too. + + name = f.name if Formula === name + + require 'open-uri' + require 'yaml' + + issues = [] + + open("http://github.com/api/v2/yaml/issues/search/mxcl/homebrew/open/"+name) do |f| + YAML::load(f.read)['issues'].each do |issue| + issues << 'http://github.com/mxcl/homebrew/issues/#issue/%s' % issue['number'] + end + end + + issues +rescue + [] +end def clean f Cleaner.new f diff --git a/bin/brew b/bin/brew index 8863945741..081bb2845b 100755 --- a/bin/brew +++ b/bin/brew @@ -326,12 +326,18 @@ rescue Interrupt => e exit 130 rescue BuildError => e e.backtrace[1] =~ %r{Library/Formula/(.+)\.rb:(\d+)} - puts "http://github.com/mxcl/homebrew/blob/master/Library/Formula/#{$1}.rb#L#{$2}" + formula_name = $1 + puts "http://github.com/mxcl/homebrew/blob/master/Library/Formula/#{formula_name}.rb#L#{$2}" ohai "Environment" dump_config puts "Exit status: #{e.status.exitstatus}" onoe e puts PLEASE_REPORT_BUG + # this feature can be slow (depends on network conditions and if github is up) + # so ideally we'd show feedback, eg. "checking for existin issues..." and + # then replace that string with the following when the github api returns + issues = issues_for_formula(formula_name) + puts "These existing issues may help you:", *issues unless issues.empty? exit 1 rescue RuntimeError, SystemCallError => e onoe e