Class: Lh2gh::CLI

Inherits:
Thor
  • Object
show all
Includes:
Octopi
Defined in:
lib/lh2gh/cli.rb

Instance Method Summary collapse

Instance Method Details

#migrateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/lh2gh/cli.rb', line 13

def migrate
  Lighthouse. = options[:lh_account]
  Lighthouse.token = options[:lh_token]
  project = Lighthouse::Project.find :first
  tickets = Lighthouse::Ticket.find :all, :params => { :project_id => project.id }
  repo_user, repo_name = options[:gh_repository].split '/'

  authenticated do
    repo = Octopi::Repository.find :name => repo_name, :user => repo_user
    tickets.each do |ticket|
      new_body = "Imported from lighthouse. Original ticket at: #{ticket.url}. Created by #{ticket.creator_name} - #{ticket.created_at}\n\n#{ticket.original_body}"
      params = {:title => ticket.title, :body => new_body}

      issue = Octopi::Issue.open :repo => repo, :params => params
      ticket.tags.each { |tag| issue.add_label URI.escape(tag) }
      issue.add_label ticket.state
      issue.close! if ticket.closed
      if ticket.respond_to? :versions
        comments = ticket.versions
        comments.shift
        comments.each do |comment|
          next if comment.body.blank?
          issue.comment "Imported from Lighthouse. Comment by #{comment.user_name} - #{comment.created_at}\n\n#{comment.body}"
        end
      end
    end
  end
end

#versionObject



44
45
46
# File 'lib/lh2gh/cli.rb', line 44

def version
  puts "Lighthouse 2 Github v#{Lh2gh::VERSION}"
end