Skip to content

Instantly share code, notes, and snippets.

@deanpcmad
Created May 20, 2015 09:36
Show Gist options
  • Save deanpcmad/822ab4f7660e56043673 to your computer and use it in GitHub Desktop.
Save deanpcmad/822ab4f7660e56043673 to your computer and use it in GitHub Desktop.
Codebase to Gitlab
class CodebaseGitlab
Gitlab.configure do |config|
config.endpoint = ""
config.private_token = ""
end
CodebaseApi.account_user = "account/user"
CodebaseApi.api_key = "key"
@codebase_project = "dashboard"
@project = "voupe%2Fdash"
project = CodebaseApi::Project.view(@codebase_project)
pages = 15
alltickets = []
begin
pages.times do |p|
alltickets.push(*CodebaseApi::Request.request("#{project["project"]["permalink"]}/tickets?page=#{p+1}"))
end
rescue
end
alltickets = alltickets - [false]
alltickets.reverse.each do |t|
gitlab_issue = Gitlab.create_issue @project, t["ticket"]["summary"], {:labels => "imported"}
puts "Created #{gitlab_issue.id} #{gitlab_issue.iid} - #{gitlab_issue.title}"
notes = CodebaseApi::Ticket.show @codebase_project, t["ticket"]["ticket_id"]
notes.each do |n|
unless n["ticket_note"]["content"].empty?
issue_note = Gitlab.create_issue_note @project, gitlab_issue.id, n["ticket_note"]["content"]
puts " Created note #{issue_note.id}"
end
end
if !t["ticket"]["status"].empty?
if t["ticket"]["status"]["name"] == "Completed"
Gitlab.close_issue @project, gitlab_issue.id
puts " Closed issue"
elsif t["ticket"]["status"]["name"] == "Invalid"
Gitlab.close_issue @project, gitlab_issue.id
puts " Closed issue"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment