Skip to content

Instantly share code, notes, and snippets.

@Vaysman
Forked from ryanb/README.md
Created May 16, 2011 08:58
Show Gist options
  • Save Vaysman/974117 to your computer and use it in GitHub Desktop.
Save Vaysman/974117 to your computer and use it in GitHub Desktop.
My Github Issues

First install the required gems:

gem install octokit awesomeprint rainbow

Then run it to extract all of your open GitHub issues into files (with comments).

ruby my-gh-issues.rb

Take a look at the issue directory for all issues. Pass specific repositories to only pull those issues.

ruby my-gh-issues.rb cancan railscasts

Note, you may get a 403 error if you have a lot of issues. I'm guessing this is because GitHub is throttling how many requests you can send. Just run the script again and it will skip over the already pulled issues.

Special thanks to the creator of this original gist and the authors of the gems.

#!/usr/bin/env ruby
#
# A quick script to dump an overview of all the open issues in all my github projects
#
require 'fileutils'
require 'octokit'
require 'awesome_print'
require 'rainbow'
repos = $*
options = {
:login => %x[ git config --get github.user ].strip,
:token => %x[ git config --get github.token ].strip
}
client = Octokit::Client.new( options )
key_width = 15
label_color = Hash.new( :cyan )
label_color['bug'] = :red
label_color['feature'] = :green
label_color['todo'] = :blue
client.list_repos.each do |repo|
next if repo.fork
next unless repo.open_issues > 0
next if repos.size > 0 && !repos.include?(repo.name)
print "Repository : ".rjust( key_width ).foreground( :green ).bright
puts repo.name
FileUtils.mkdir_p("issues/#{repo.name}") unless File.exist? "issues/#{repo.name}"
print "Issue Count : ".rjust( key_width ).foreground( :yellow ).bright
puts repo.open_issues
client.issues( repo ).each do |issue|
print ("%3d : " % issue.number).rjust( key_width).foreground( :white ).bright
labels = []
if not issue.labels.empty? then
issue.labels.each do |l|
labels << l.foreground( label_color[l] ).bright
end
end
print labels.join(' ') + " "
puts issue.title
path = "issues/#{repo.name}/issue-#{issue.number}.txt"
unless File.exist? path
File.open(path, "w") do |f|
comments = client.issue_comments(repo, issue.number)
f.puts "\##{issue.number} #{issue.title}"
f.puts "By #{issue.user} on #{issue.created_at}"
f.puts "Labels: #{issue.labels.join(" ")}" unless issue.labels.empty?
f.puts
f.puts issue.body
f.puts
f.puts "Comments: #{comments.size}"
comments.each do |comment|
f.puts "--------"
f.puts "From #{comment.user} on #{comment.created_at}"
f.puts
f.puts comment.body
f.puts
end
end
end
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment