github-issue-importer 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9d7111c47b15277f9860b27044e33332e6a8162a
4
+ data.tar.gz: fa8f50c02dd163682a844253bd7c4789a89921be
5
+ SHA512:
6
+ metadata.gz: 275345f94b66568224246b195a5d05be44754b6c1c5ee9801315ee4d6202da5cd3e149454782a7f72d7c831ccbf552b53d9d4755b0b085efdbc182246f7e5eac
7
+ data.tar.gz: edeb57bf4ce697f24ff79131bbeb421168fdae2ea9ae8129e524f9d8fc0799bd44480988c0288b8be4bb0ffb518abd77cde8371631863c01e3e1fc6d82820cdf
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # 0.0.2 (2013-02-22)
2
+
3
+ * Add homepage and license to GEM spec (@johnf)
4
+ * Define blank? (@johnf)
5
+ * Move to Github v3 API (@dlitz)
6
+
7
+ # 0.0.1 (2011-04-08)
8
+
9
+ * Initial release
@@ -1,10 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'trollop'
4
- require 'octopi'
4
+ require 'octokit'
5
5
 
6
6
  require 'github-issue-importer'
7
7
 
8
+ # Define blank? if it's not already defined
9
+ unless nil.respond_to? :blank?
10
+ class Object
11
+ def blank?
12
+ respond_to?(:empty?) ? empty? : !self
13
+ end
14
+ end
15
+ end
8
16
 
9
17
  options = Trollop::options do
10
18
  banner <<-EOS
@@ -35,17 +43,20 @@ Trollop::die :'gh-repo', "Please specify a GitHub Repository" if options[:'gh-re
35
43
  options[:'gh-repo-user'], options[:'gh-repo-name'] = options[:'gh-repo'].split('/')
36
44
  Trollop::die :'gh-repo', "Please specify a valid GitHub Repository" if options[:'gh-repo-user'].nil? or options[:'gh-repo-name'].nil?
37
45
 
38
- include Octopi
46
+ gh_client = Octokit::Client.new :login => options[:'gh-login'], :oauth_token => options[:'gh-token']
39
47
 
40
48
  begin
41
- gh_user = Octopi::User.find options[:'gh-repo-user']
42
- rescue Octopi::NotFound
49
+ gh_user = gh_client.user options[:'gh-repo-user']
50
+ rescue Octokit::Unauthorized, Octokit::Forbidden => e
51
+ $stderr.puts "Authorization failed: #{e}"
52
+ exit 1
53
+ rescue Octokit::NotFound
43
54
  $stderr.puts "Could not find the user #{options[:'gh-repo-user']} in the repo name it is either private or doesn't exist"
44
55
  exit 1
45
56
  end
46
57
 
47
58
  begin
48
- gh_repo = gh_user.repository options[:'gh-repo-name']
59
+ gh_repo = gh_client.repo :username => options[:'gh-repo-user'], :repo => options[:'gh-repo-name']
49
60
  rescue Octopi::NotFound
50
61
  $stderr.puts "The user #{options[:'gh-repo-user']} doesn't have a repository named #{options[:'gh-repo-name']} or it is private"
51
62
  exit 1
@@ -66,30 +77,30 @@ bug_entries.each do |bug_entry|
66
77
  body += "Launchpad Details: [#LP#{bug['id']}](#{bug['web_link']}) #{bug_owner['display_name']} - #{bug_time}"
67
78
 
68
79
  comments = launchpad.get_bug_comments bug
69
- authenticated_with :login => options[:'gh-login'], :token => options[:'gh-token'] do
70
- issue = Issue.open :user => gh_user, :repo => gh_repo, :params => { :title => bug['title'], :body => body }
71
80
 
72
- comments.shift # First comment is always the bug description
73
- comments.each do |comment|
74
- next if comment['content'].blank?
75
- comment_owner = launchpad.get_owner comment
81
+ labels = []
82
+ bug_importance = bug_entry['importance']
83
+ unless bug_importance.blank? or bug_importance == 'Undecided'
84
+ labels << bug_importance.downcase
85
+ end
76
86
 
77
- comment_time = Time.parse(comment['date_created'])
78
- body = "#{comment['content']}\n\n"
79
- body += "Launchpad Details: [#LPC#{comment['id']}](#{comment['web_link']}) #{comment_owner['display_name']} - #{comment_time}"
87
+ issue = gh_client.create_issue gh_repo.full_name, bug['title'], body, :labels => (labels.empty? ? nil : labels.join(','))
80
88
 
81
- issue.comment body
82
- end
89
+ comments.shift # First comment is always the bug description
90
+ comments.each do |comment|
91
+ next if comment['content'].blank?
92
+ comment_owner = launchpad.get_owner comment
83
93
 
84
- bug_status = bug_entry['status']
85
- if bug_status =~ /^Fix/
86
- issue.close!
87
- end
94
+ comment_time = Time.parse(comment['date_created'])
95
+ body = "#{comment['content']}\n\n"
96
+ body += "Launchpad Details: [#LPC#{comment['id']}](#{comment['web_link']}) #{comment_owner['display_name']} - #{comment_time}"
88
97
 
89
- bug_importance = bug_entry['importance']
90
- unless bug_importance.blank? or bug_importance == 'Undecided'
91
- issue.add_label bug_importance.downcase
92
- end
98
+ gh_client.add_comment gh_repo.full_name, issue.number, body
99
+ end
93
100
 
101
+ bug_status = bug_entry['status']
102
+ if bug_status =~ /^Fix/
103
+ gh_client.close_issue gh_repo.full_name, issue.number
94
104
  end
105
+
95
106
  end
@@ -8,9 +8,11 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ['John Ferlito']
10
10
  s.email = ['johnf@inodes.org']
11
- s.homepage = ""
11
+ s.homepage = 'http://github.com/johnf/github-issue-importer'
12
12
  s.summary = %q{Launchpad to Github bug importer}
13
13
  s.description = %q{Migrate bugs from a Launchpas project into Github Issues}
14
+ s.license = 'MIT'
15
+
14
16
 
15
17
  s.rubyforge_project = "github-issue-importer"
16
18
 
@@ -19,8 +21,9 @@ Gem::Specification.new do |s|
19
21
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
22
  s.require_paths = ["lib"]
21
23
 
22
- s.add_dependency('octopi')
24
+ s.add_dependency('octokit')
23
25
  s.add_dependency('trollop')
24
26
 
25
27
  s.add_development_dependency('awesome_print')
28
+ s.add_development_dependency('rake')
26
29
  end
@@ -1,7 +1,7 @@
1
1
  module Github
2
2
  module Issue
3
3
  module Importer
4
- VERSION = "0.0.1"
4
+ VERSION = '0.0.2'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,62 +1,81 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: github-issue-importer
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - John Ferlito
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-04-08 00:00:00 +10:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: octopi
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
11
+ date: 2014-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
22
17
  - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
25
20
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: trollop
29
21
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: trollop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
33
31
  - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
36
34
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
39
42
  name: awesome_print
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
40
49
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
44
59
  - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  type: :development
48
- version_requirements: *id003
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
49
69
  description: Migrate bugs from a Launchpas project into Github Issues
50
- email:
70
+ email:
51
71
  - johnf@inodes.org
52
- executables:
72
+ executables:
53
73
  - github-issue-importer
54
74
  extensions: []
55
-
56
75
  extra_rdoc_files: []
57
-
58
- files:
59
- - .gitignore
76
+ files:
77
+ - ".gitignore"
78
+ - CHANGELOG.md
60
79
  - Gemfile
61
80
  - LICENSE
62
81
  - README.md
@@ -67,33 +86,28 @@ files:
67
86
  - lib/github-issue-importer.rb
68
87
  - lib/github-issue-importer/launchpad.rb
69
88
  - lib/github-issue-importer/version.rb
70
- has_rdoc: true
71
- homepage: ""
72
- licenses: []
73
-
89
+ homepage: http://github.com/johnf/github-issue-importer
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
74
93
  post_install_message:
75
94
  rdoc_options: []
76
-
77
- require_paths:
95
+ require_paths:
78
96
  - lib
79
- required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
82
99
  - - ">="
83
- - !ruby/object:Gem::Version
84
- version: "0"
85
- required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
88
104
  - - ">="
89
- - !ruby/object:Gem::Version
90
- version: "0"
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
91
107
  requirements: []
92
-
93
108
  rubyforge_project: github-issue-importer
94
- rubygems_version: 1.5.0
109
+ rubygems_version: 2.2.0
95
110
  signing_key:
96
- specification_version: 3
111
+ specification_version: 4
97
112
  summary: Launchpad to Github bug importer
98
113
  test_files: []
99
-