Switch to "legacy" GitHub search API

GitHub's v2 API entry point is gone, but search as been ported to API v3
as a "legacy" feature.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-06-12 11:51:05 -05:00
parent 9e2fc82ad6
commit de5f0a8e9b

View File

@ -523,17 +523,16 @@ module GitHub extend self
name = f.name if Formula === name name = f.name if Formula === name
require 'open-uri' require 'open-uri'
require 'yaml' require 'vendor/multi_json'
issues = [] issues = []
open "http://github.com/api/v2/yaml/issues/search/mxcl/homebrew/open/#{name}" do |f| uri = URI.parse("https://api.github.com/legacy/issues/search/mxcl/homebrew/open/#{name}")
yaml = YAML::load(f.read);
yaml['issues'].each do |issue| open uri do |f|
MultiJson.decode(f.read)['issues'].each do |issue|
# don't include issues that just refer to the tool in their body # don't include issues that just refer to the tool in their body
if issue['title'].include? name issues << issue['html_url'] if issue['title'].include? name
issues << issue['html_url']
end
end end
end end
@ -547,11 +546,11 @@ module GitHub extend self
require 'vendor/multi_json' require 'vendor/multi_json'
query = rx.source.delete('.*').gsub('\\', '') query = rx.source.delete('.*').gsub('\\', '')
uri = URI.parse("http://github.com/api/v2/json/issues/search/mxcl/homebrew/open/#{query}") uri = URI.parse("https://api.github.com/legacy/issues/search/mxcl/homebrew/open/#{query}")
open uri do |f| open uri do |f|
MultiJson.decode(f.read)["issues"].each do |pull| MultiJson.decode(f.read)['issues'].each do |pull|
yield pull['pull_request_url'] if rx.match pull['title'] and pull["pull_request_url"] yield pull['pull_request_url'] if rx.match pull['title'] and pull['pull_request_url']
end end
end end
rescue rescue