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 <mistydemeo@gmail.com>
This commit is contained in:
parent
6626966ddd
commit
7962b15a98
@ -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
|
||||
[]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user