Created
April 4, 2015 00:37
-
-
Save nilsding/bba41e865d574658fb20 to your computer and use it in GitHub Desktop.
export issues for a GitHub repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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