Created
August 29, 2013 23:55
-
-
Save whatupdave/6384811 to your computer and use it in GitHub Desktop.
Download github issues to json
This file contains 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
require 'octokit' | |
require 'json' | |
# AUTH=user:pwd ruby issues.rb rails/rails | |
login, pwd = (ENV['AUTH'] || ':').split(':') | |
repo = ARGV.shift | |
client = Octokit::Client.new(:login => login, :password => pwd) | |
$stderr.puts "Getting issues from #{repo}" | |
temp_issues = [] | |
issues = [] | |
page = 0 | |
begin | |
$stderr.puts " page #{page}" | |
page = page +1 | |
temp_issues = client.list_issues(repo, :state => "open", :page => page) | |
issues = issues + temp_issues | |
end while not temp_issues.empty? | |
$stderr.puts "Processing #{issues.size} issues..." | |
h = [] | |
issues.take(5).each do |issue| | |
comments = issue.rels[:comments].get.data.map do |c| | |
{ | |
created_at: c.created_at, | |
updated_at: c.updated_at, | |
login: c.user.login, | |
body: c.body, | |
} | |
end | |
h << { | |
created_at: issue.created_at, | |
updated_at: issue.updated_at, | |
login: issue.user.login, | |
title: issue.title, | |
body: issue.body, | |
labels: issue.labels.map {|l| l.name }, | |
comments: comments | |
} | |
end | |
puts h.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment