Skip to content

Instantly share code, notes, and snippets.

@nilsding
Created April 4, 2015 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilsding/bba41e865d574658fb20 to your computer and use it in GitHub Desktop.
Save nilsding/bba41e865d574658fb20 to your computer and use it in GitHub Desktop.
export issues for a GitHub repo
#!/usr/bin/env ruby
#
# Usage:
# ruby issues_exporter.rb > exported_repo.yml
# Settings:
user = 'retrospring'
repo = 'bugs'
username = 'your-oauth-token-here' # see https://github.com/settings/applications#personal-access-tokens
require 'httparty'
require 'json'
require 'yaml'
issues_url = "https://api.github.com/repos/#{user}/#{repo}/issues"
issues = []
cur_id = 1
loop do
STDERR.print "fetching #{cur_id}... "
issue = JSON.parse(HTTParty.get(issues_url + "/#{cur_id}", basic_auth: { username: username, password: 'x-oauth-basic' }).body)
if issue['message'] == "Not Found"
STDERR.puts "not found"
break
end
if issue['comments'] > 0
STDERR.print "comments"
issue['comment_contents'] = JSON.parse(HTTParty.get(issue['comments_url'], basic_auth: { username: username, password: 'x-oauth-basic' }).body)
end
issues << issue
cur_id += 1
STDERR.puts
end
puts issues.to_yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment