Skip to content

Instantly share code, notes, and snippets.

@rodrei
Created November 5, 2012 16:09
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 rodrei/4018021 to your computer and use it in GitHub Desktop.
Save rodrei/4018021 to your computer and use it in GitHub Desktop.
Github Issues export to Assembla CSV
require 'github_api'
components = %w{ tag1 tag2 tag3 tag4 }
users = {
'github-username' => 'new-system-username'
}
assembla_issues = []
client = Github.new login: 'user', password: 'password'
github_issues = client.issues.list_repo 'user', 'repo', per_page: 100
puts "FETCHED #{github_issues.count} issues"
github_issues.each do |issue|
assembla_issues << {
component: (issue.labels.map(&:name) & components).first,
summary: issue.title.gsub('"', '\"'),
assigned_to: issue.assignee ? (users[issue.assignee.login] || issue.assignee.login) : '',
description: issue.body.gsub('"', '\"')
}
end
File.open 'tickets.csv', 'w+' do |file|
file << "summary,assigned_to,description,component\n"
assembla_issues.each do |issue|
file << ["\"#{issue[:summary]}\"", issue[:assigned_to], "\"#{issue[:description]}\"", issue[:component]].join(',')
file << "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment