Skip to content

Instantly share code, notes, and snippets.

@whatupdave
Created August 29, 2013 23:55
Show Gist options
  • Save whatupdave/6384811 to your computer and use it in GitHub Desktop.
Save whatupdave/6384811 to your computer and use it in GitHub Desktop.
Download github issues to json
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