Skip to content

Instantly share code, notes, and snippets.

@chip
Created October 26, 2011 19:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chip/1317476 to your computer and use it in GitHub Desktop.
Save chip/1317476 to your computer and use it in GitHub Desktop.
Convert Basecamp tasks to Github issues
require 'rubygems'
require 'hash'
require 'active_resource'
require 'basecamp'
require 'httparty'
require 'json'
class GithubIssues
include HTTParty
base_uri "https://api.github.com"
basic_auth '', ''
default_params :output => 'json'
format :json
def self.add(org, repo, title, body, labels=[])
options = {:body => {:title => title, :body => body, :labels => labels }.to_json}
resp = post "/repos/#{org}/#{repo}/issues", options
puts 'resp: ' + resp.inspect
end
end
GITHUB_ORG = ''
GITHUB_REPO = ''
BASECAMP_DOMAIN = ''
BASECAMP_TOKEN = ''
PROJECT_ID = ''
conn = Basecamp.establish_connection!(BASECAMP_DOMAIN, BASECAMP_TOKEN, 'X', true)
lists_to_convert = ['Sprint']
todo_lists = Basecamp::TodoList.all(PROJECT_ID)
todo_lists.each do |todo_list|
next unless lists_to_convert.include?(todo_list.name)
puts todo_list.name + "\n"
todo_items = Basecamp::TodoItem.find(:all, :params => { :todo_list_id => todo_list.id })
todo_items.each do |item|
title = item.content
body = "https://#{BASECAMP_DOMAIN}/projects/#{PROJECT_ID}/todo_items/#{item.id}/comments"
labels = ['BASECAMP']
p item.content
p item.inspect
if item.completed == false
puts "GithubIssues.add(#{GITHUB_ORG}, #{GITHUB_REPO}, #{title}, #{body}, #{labels})"
#GithubIssues.add(org, repo, title, body, labels)
else
puts "item #{item.id} was completed"
end
puts "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment