Skip to content

Instantly share code, notes, and snippets.

@badboy badboy/

forked from ryanb/
Last active Nov 7, 2018
What would you like to do?
Save github issues offline.

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,
:oauth_token => %x[ git config --get github.token ].strip
client = options )
key_width = 15
label_color = :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?(
print "Repository : ".rjust( key_width ).foreground( :green ).bright
FileUtils.mkdir_p("issues/#{}") unless File.exist? "issues/#{}"
print "Issue Count : ".rjust( key_width ).foreground( :yellow ).bright
puts repo.open_issues
client.issues( repo.full_name ).each do |issue|
print ("%3d : " % issue.number).rjust( key_width).foreground( :white ).bright
labels = []
unless issue.labels.empty?
issue.labels.each do |l|
labels << label_color[l] ).bright
print labels.join(' ') + " "
puts issue.title
path = "issues/#{}/issue-#{issue.number}.txt"
unless File.exist? path, "w") do |f|
comments = client.issue_comments(repo.full_name, issue.number)
f.puts "\##{issue.number} #{issue.title}"
f.puts "By #{issue.user.login} on #{issue.created_at}"
f.puts "Labels: #{issue.labels.join(" ")}" unless issue.labels.empty?
f.puts issue.body
f.puts "Comments: #{comments.size}"
comments.each do |comment|
f.puts "--------"
f.puts "From #{comment.user.login} on #{comment.created_at}"
f.puts comment.body

This comment has been minimized.

Copy link

Naramsim commented Jun 14, 2018

How to save also closed issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.