From 7962b15a982cef28cf2356fff1f534000fdb333a Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Fri, 13 Jan 2012 18:30:40 -0600 Subject: search: use v2 API The v3 API currently lacks a search feature. Use the v2 API instead for much faster pull request filtering. Closes Homebrew/homebrew#9592. Signed-off-by: Misty De Meo --- Library/Homebrew/utils.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 71417e61a..644023a0c 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -433,20 +433,14 @@ module GitHub extend self require 'vendor/multi_json' pulls = [] - uri = URI.parse("https://api.github.com/repos/mxcl/homebrew/pulls") - uri.query = "per_page=100" + query = rx.source.delete '.*' + uri = URI.parse("http://github.com/api/v2/json/issues/search/mxcl/homebrew/open/#{query}") open uri do |f| - MultiJson.decode((f.read)).each do |pull| - pulls << pull['html_url'] if rx.match pull['title'] + MultiJson.decode(f.read)["issues"].each do |pull| + pulls << pull['pull_request_url'] if rx.match pull['title'] and pull["pull_request_url"] end - - uri = if f.meta['link'] =~ /rel="next"/ - f.meta['link'].slice(URI.regexp) - else - nil - end - end while uri + end pulls rescue [] -- cgit v1.2.3