lh2gh 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ vendor/ruby
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lh2gh.gemspec
4
+ gemspec
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber'
5
+ require 'cucumber/rake/task'
6
+
7
+ Cucumber::Rake::Task.new(:features) do |t|
8
+ t.cucumber_opts = "features --tags ~@wip --format pretty"
9
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
3
+ require 'lh2gh/cli'
4
+ require 'logger'
5
+
6
+ LOGGER = Logger.new STDOUT
7
+ LOGGER.level = Logger::INFO
8
+
9
+ Lh2gh::CLI.start
10
+
11
+ LOGGER.close
@@ -0,0 +1,14 @@
1
+ Feature: Running
2
+ As a pragmatic developer
3
+ In order to consolidate my resources
4
+ I want to be able to migrate my Lighthouse tickets to GitHub issues
5
+
6
+ Scenario: Finding out the version
7
+ When I run `lh2gh version`
8
+ Then the output should contain "Lighthouse 2 Github v0.0.1"
9
+
10
+ Scenario: Asking for help
11
+ When I run `lh2gh help`
12
+ Then the output should contain "Tasks:"
13
+ And the output should contain "lh2gh help"
14
+ And the output should contain "lh2gh version"
@@ -0,0 +1 @@
1
+ require 'aruba/cucumber'
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "lh2gh/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "lh2gh"
7
+ s.version = Lh2gh::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Ben Langfeld"]
10
+ s.email = ["ben@langfeld.me"]
11
+ s.homepage = "http://langfeld.me"
12
+ s.summary = %q{Move from Lighthouse to Github Issues}
13
+ s.description = %q{Export all of your tickets from Lighthouse to Github issues in one fell swoop.}
14
+
15
+ s.rubyforge_project = "lh2gh"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.required_ruby_version = '>= 1.9.2'
23
+
24
+ s.add_dependency 'thor'
25
+ s.add_dependency 'benlangfeld-lighthouse-api'
26
+ s.add_dependency 'addressable'
27
+ s.add_dependency 'octopi'
28
+ s.add_development_dependency 'rspec'
29
+ s.add_development_dependency 'cucumber'
30
+ s.add_development_dependency 'aruba'
31
+ end
@@ -0,0 +1,55 @@
1
+ require 'lighthouse-api'
2
+ require 'octopi'
3
+
4
+ module Lh2gh
5
+ # Your code goes here...
6
+ end
7
+
8
+
9
+ # Horrible monkey patch to Octopi - should be able to get rid of this soon: https://github.com/fcoury/octopi/issues/55
10
+ module Octopi
11
+ class Api
12
+ def submit(path, params = {}, klass=nil, format = :yaml, &block)
13
+ # Ergh. Ugly way to do this. Find a better one!
14
+ cache = params.delete(:cache)
15
+ cache = true if cache.nil?
16
+ cache = false
17
+ params.each_pair do |k,v|
18
+ if path =~ /:#{k.to_s}/
19
+ params.delete(k)
20
+ path = path.gsub(":#{k.to_s}", v)
21
+ end
22
+ end
23
+ begin
24
+ key = "#{Api.api.class.to_s}:#{path}"
25
+ resp = if cache
26
+ APICache.get(key, :cache => 61) do
27
+ yield(path, params, format, auth_parameters)
28
+ end
29
+ else
30
+ yield(path, params, format, auth_parameters)
31
+ end
32
+ rescue Net::HTTPBadResponse
33
+ raise RetryableAPIError
34
+ end
35
+
36
+ raise RetryableAPIError, resp.code.to_i if RETRYABLE_STATUS.include? resp.code.to_i
37
+ # puts resp.code.inspect
38
+ raise NotFound, klass || self.class if resp.code.to_i == 404
39
+ raise APIError,
40
+ "GitHub returned status #{resp.code}" unless ((resp.code.to_i == 200) || (resp.code.to_i == 201))
41
+ # FIXME: This fails for showing raw Git data because that call returns
42
+ # text/html as the content type. This issue has been reported.
43
+
44
+ # It happens, in tests.
45
+ return resp if resp.headers.empty?
46
+ content_type = Array === resp.headers['content-type'] ? resp.headers['content-type'] : [resp.headers['content-type']]
47
+ ctype = content_type.first.split(";").first
48
+ raise FormatError, [ctype, format] unless CONTENT_TYPE[format.to_s].include?(ctype)
49
+ if format == 'yaml' && resp['error']
50
+ raise APIError, resp['error']
51
+ end
52
+ resp
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,49 @@
1
+ require 'thor'
2
+ require 'lh2gh'
3
+ require 'uri'
4
+
5
+ module Lh2gh
6
+ class CLI < Thor
7
+ include Octopi
8
+
9
+ desc 'migrate', 'Migrate tickets from Lighthouse to Github Issues'
10
+ method_option :lh_account, :type => :string, :required => true
11
+ method_option :lh_token, :type => :string, :required => true
12
+ method_option :gh_repository, :type => :string, :required => true, :banner => "rails/rails"
13
+ def migrate
14
+ Lighthouse.account = options[:lh_account]
15
+ Lighthouse.token = options[:lh_token]
16
+ project = Lighthouse::Project.find :first
17
+ tickets = Lighthouse::Ticket.find :all, :params => { :project_id => project.id }
18
+ repo_user, repo_name = options[:gh_repository].split '/'
19
+
20
+ authenticated do
21
+ repo = Octopi::Repository.find :name => repo_name, :user => repo_user
22
+ tickets.each do |ticket|
23
+ new_body = "Imported from lighthouse. Original ticket at: #{ticket.url}. Created by #{ticket.creator_name} - #{ticket.created_at}\n\n#{ticket.original_body}"
24
+ params = {:title => ticket.title, :body => new_body}
25
+
26
+ issue = Octopi::Issue.open :repo => repo, :params => params
27
+ ticket.tags.each { |tag| issue.add_label URI.escape(tag) }
28
+ issue.add_label ticket.state
29
+ issue.close! if ticket.closed
30
+ if ticket.respond_to? :versions
31
+ comments = ticket.versions
32
+ comments.shift
33
+ comments.each do |comment|
34
+ next if comment.body.blank?
35
+ issue.comment "Imported from Lighthouse. Comment by #{comment.user_name} - #{comment.created_at}\n\n#{comment.body}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ desc 'version', 'Print version info for Lighthouse 2 Github'
43
+ map %w(-v --version) => :version
44
+ def version
45
+ puts "Lighthouse 2 Github v#{Lh2gh::VERSION}"
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module Lh2gh
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lh2gh
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Ben Langfeld
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-11 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: thor
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: benlangfeld-lighthouse-api
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: addressable
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: octopi
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ type: :development
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: cucumber
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: aruba
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ type: :development
92
+ version_requirements: *id007
93
+ description: Export all of your tickets from Lighthouse to Github issues in one fell swoop.
94
+ email:
95
+ - ben@langfeld.me
96
+ executables:
97
+ - lh2gh
98
+ extensions: []
99
+
100
+ extra_rdoc_files: []
101
+
102
+ files:
103
+ - .gitignore
104
+ - Gemfile
105
+ - Rakefile
106
+ - bin/lh2gh
107
+ - features/running.feature
108
+ - features/support/env.rb
109
+ - lh2gh.gemspec
110
+ - lib/lh2gh.rb
111
+ - lib/lh2gh/cli.rb
112
+ - lib/lh2gh/version.rb
113
+ has_rdoc: true
114
+ homepage: http://langfeld.me
115
+ licenses: []
116
+
117
+ post_install_message:
118
+ rdoc_options: []
119
+
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: 1.9.2
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ requirements: []
135
+
136
+ rubyforge_project: lh2gh
137
+ rubygems_version: 1.6.1
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: Move from Lighthouse to Github Issues
141
+ test_files:
142
+ - features/running.feature
143
+ - features/support/env.rb