Created
March 3, 2011 19:01
-
-
Save msmithstubbs/853288 to your computer and use it in GitHub Desktop.
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
# | |
# Quick script to migrate issues from Pivotal Tracker to GitHub | |
# | |
# Based on https://github.com/suitmymind/lighthouse-to-github/blob/master/migrate-lh-to-gh.rb | |
# and pivotal-tracker gem: https://github.com/jsmestad/pivotal-tracker | |
# | |
# | |
require 'pivotal-tracker' | |
require 'yaml' | |
GITHUB_LOGIN = "your_username" | |
GITHUB_API_TOKEN = "your_token" | |
GITHUB_PROJECT = "Your-Project-Name" | |
GITHUB_NEW_ISSUE_API_URL = "https://github.com/api/v2/yaml/issues/open/#{GITHUB_LOGIN}/#{GITHUB_PROJECT}" | |
GITHUB_CLOSE_ISSUE_API_URL = "https://github.com/api/v2/yaml/issues/close/#{GITHUB_LOGIN}/#{GITHUB_PROJECT}" | |
GITHUB_ADD_COMMENT_API_URL = "https://github.com/api/v2/yaml/issues/comment/#{GITHUB_LOGIN}/#{GITHUB_PROJECT}" | |
GITHUB_ADD_LABEL_API_URL = "https://github.com/api/v2/yaml/issues/label/add/#{GITHUB_LOGIN}/#{GITHUB_PROJECT}" | |
PivotalTracker::Client.token('[email protected]', 'your_password') | |
@a_project = PivotalTracker::Project.find(ARGV[0]) # specify the project ID as the first argument | |
@a_project.stories.all.each do |story| | |
next if story.story_type == 'release' | |
puts "#{story.name}: #{story.story_type}" | |
title = story.name | |
body = story.description || "" | |
# escape single quote | |
body.gsub!(/'/,"’") | |
gh_return_value = `curl -F 'login=#{GITHUB_LOGIN}' -F 'token=#{GITHUB_API_TOKEN}' -F "title=#{title}" -F 'body=#{body}' #{GITHUB_NEW_ISSUE_API_URL}` | |
gh_issue_id = YAML::load(gh_return_value)["issue"]["number"] | |
if story.current_state == 'accepted' # mark this one as closed | |
gh_return_value = `curl -F 'login=#{GITHUB_LOGIN}' -F 'token=#{GITHUB_API_TOKEN}' #{GITHUB_CLOSE_ISSUE_API_URL}/#{gh_issue_id}` | |
end | |
if story.story_type == 'chore' | |
gh_return_value = `curl -F 'login=#{GITHUB_LOGIN}' -F 'token=#{GITHUB_API_TOKEN}' #{GITHUB_ADD_LABEL_API_URL}/Chore/#{gh_issue_id}` | |
end | |
if story.story_type == 'feature' | |
gh_return_value = `curl -F 'login=#{GITHUB_LOGIN}' -F 'token=#{GITHUB_API_TOKEN}' #{GITHUB_ADD_LABEL_API_URL}/Feature/#{gh_issue_id}` | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment