Skip to content

Instantly share code, notes, and snippets.

@naush
Created January 29, 2015 18:12
Show Gist options
  • Save naush/d82189fc872e0a3c60a1 to your computer and use it in GitHub Desktop.
Save naush/d82189fc872e0a3c60a1 to your computer and use it in GitHub Desktop.
require 'octokit'
require 'csv'
client = Octokit::Client.new(access_token: 'ACCESS_TOKEN')
client.auto_paginate = true
open = client.issues('namely/issues', headers: { 'x-oauth-basic' => 'ACCESS_TOKEN' })
closed = client.issues('namely/issues', headers: { 'x-oauth-basic' => 'ACCESS_TOKEN' }, state: 'closed')
issues = open + closed
CSV.open("filename.csv", "wb") do |csv|
# Github API Documentation on Issues: https://developer.github.com/v3/issues/
csv << ['number', 'title', 'user', 'labels', 'state', 'assignee', 'milestone', 'created_at', 'closed_at']
issues.each do |issue|
hash = issue.to_hash
csv << [
hash[:number],
hash[:title],
hash[:user][:login],
hash[:labels].collect { |label| label[:name] }.join(' ,'),
(hash[:assignee] || {})[:login] || '',
hash[:milsetone],
hash[:created_at],
hash[:closed_at]
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment