Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Forked from ryanb/README.md
Created July 18, 2012 13:28
Show Gist options
  • Save iloveitaly/3136207 to your computer and use it in GitHub Desktop.
Save iloveitaly/3136207 to your computer and use it in GitHub Desktop.
Print GitHub issues for all your repos – or a specific repo – out on the command line. Filter by label.

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 'optparse'
require 'octokit'
require 'awesome_print'
require 'rainbow'
options = {
:login => %x[ git config --get github.user ].strip,
:oauth_token => %x[ git config --get github.token ].strip,
:labels => ''
}
client = Octokit::Client.new( options )
OptionParser.new do |opts|
# restrict to specific label
opts.on('-l LABEL') { |l| options[:labels] = l }
end.parse!(ARGV)
repo_restrict_list = $*
# markdown formatted output
client.list_repos.each do |repo|
next if repo.fork
next unless repo.open_issues > 0
next if repo_restrict_list.size > 0 && !repo_restrict_list.include?(repo.name)
print "## Repository: "
puts repo.name
print "### Issue Count: "
puts repo.open_issues
client.list_issues( repo.full_name, per_page: 200, labels: options[:labels] ).each do |issue|
labels = []
if not issue.labels.empty? then
issue.labels.each do |l|
# labels << l.foreground( label_color[l] ).bright
labels << l["name"]
end
end
puts "* #{issue.title}. **Labels:** #{labels.join(', ')}"
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment