aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorJack Nagel2012-01-11 20:49:08 -0600
committerJack Nagel2012-01-11 21:11:53 -0600
commitc00dbf3e41f88f5752affbd8f422a175f5dc654c (patch)
tree997d62c9faff5ecfd1b4b3e2e292c85a451388b0 /Library/Homebrew/utils.rb
parent601c001c5c09aeed52499e0f184855c11e5c14e4 (diff)
downloadhomebrew-c00dbf3e41f88f5752affbd8f422a175f5dc654c.tar.bz2
search: return matches from open pull requests
When search can't find any local results, hit the GitHub API and search the titles of pending pull requests. This will help people find the many proposed formulae and prevent them from wasting time duplicating them. Closes #9018. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 97fa46f7b..71417e61a 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -427,4 +427,28 @@ module GitHub extend self
rescue
[]
end
+
+ def find_pull_requests rx
+ require 'open-uri'
+ require 'vendor/multi_json'
+
+ pulls = []
+ uri = URI.parse("https://api.github.com/repos/mxcl/homebrew/pulls")
+ uri.query = "per_page=100"
+
+ open uri do |f|
+ MultiJson.decode((f.read)).each do |pull|
+ pulls << pull['html_url'] if rx.match pull['title']
+ end
+
+ uri = if f.meta['link'] =~ /rel="next"/
+ f.meta['link'].slice(URI.regexp)
+ else
+ nil
+ end
+ end while uri
+ pulls
+ rescue
+ []
+ end
end