Created
May 16, 2013 09:52
-
-
Save dictav/5590650 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# coding:utf-8 | |
require 'net/https' | |
require 'json' | |
origin_url = `git config remote.origin.url` | |
matches = origin_url.match %r,git@(github.com|bitbucket.org):(.+)/(.+).git, | |
dummy,service,user,repo = matches.to_a | |
case service | |
when 'bitbucket.org' | |
host = 'api.bitbucket.org' | |
path = ['/1.0/repositories',user,repo,'issues?status=open&status=new'].join('/') | |
when 'github.com' | |
raise 'not implement' | |
else | |
raise 'not repository' | |
end | |
puts origin_url | |
https = Net::HTTP.new(host,443) | |
https.use_ssl = true | |
issues = https.start { | |
req = Net::HTTP::Get.new path | |
response = https.request req | |
JSON.parse(response.body)['issues'] | |
} | |
if issues | |
for iss in issues | |
puts "%3d : %s" % [iss['local_id'],iss['title']] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment