Skip to content
Snippets Groups Projects
Commit 8d100a05 authored by Misty De Meo's avatar Misty De Meo
Browse files

search: return results while parsing


Instead of returning a full list of results after parsing, yield and
print each result as it's found for a snappier user experience.

Closes Homebrew/homebrew#9576.

Signed-off-by: default avatarMisty De Meo <mistydemeo@gmail.com>
parent 9a774ac0
No related branches found
No related tags found
No related merge requests found
......@@ -29,10 +29,8 @@ module Homebrew extend self
end
if search_results.empty? and not blacklisted? query
pulls = GitHub.find_pull_requests rx
unless pulls.empty?
puts "Open pull requests matching \"#{query}\":", *pulls.map { |p| " #{p}" }
end
puts "No formula found for \"#{query}\". Searching open pull requests..."
GitHub.find_pull_requests(rx) { |pull| puts pull }
end
end
end
......
......@@ -432,17 +432,15 @@ module GitHub extend self
require 'open-uri'
require 'vendor/multi_json'
pulls = []
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)["issues"].each do |pull|
pulls << 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
pulls
rescue
[]
nil
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment