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'
|
require 'vendor/multi_json'
|
||||||
|
|
||||||
pulls = []
|
pulls = []
|
||||||
uri = URI.parse("https://api.github.com/repos/mxcl/homebrew/pulls")
|
query = rx.source.delete '.*'
|
||||||
uri.query = "per_page=100"
|
uri = URI.parse("http://github.com/api/v2/json/issues/search/mxcl/homebrew/open/#{query}")
|
||||||
|
|
||||||
open uri do |f|
|
open uri do |f|
|
||||||
MultiJson.decode((f.read)).each do |pull|
|
MultiJson.decode(f.read)["issues"].each do |pull|
|
||||||
pulls << pull['html_url'] if rx.match pull['title']
|
pulls << pull['pull_request_url'] if rx.match pull['title'] and pull["pull_request_url"]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
uri = if f.meta['link'] =~ /rel="next"/
|
|
||||||
f.meta['link'].slice(URI.regexp)
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end while uri
|
|
||||||
pulls
|
pulls
|
||||||
rescue
|
rescue
|
||||||
[]
|
[]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user