Skip to content

Instantly share code, notes, and snippets.

@dictav
Created May 16, 2013 09:52
Show Gist options
  • Save dictav/5590650 to your computer and use it in GitHub Desktop.
Save dictav/5590650 to your computer and use it in GitHub Desktop.
#! /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