github-issue-importer 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1bd733521e570924aef4316098894ed10bf6d713
4
- data.tar.gz: e4332ecf36101ef4f41e492c931556fd64904a18
2
+ SHA256:
3
+ metadata.gz: f651d414251fa55a7df49d68e70b9950be97d6ae49112853edd61bdb91133331
4
+ data.tar.gz: 625ffb1a83b11ee250ec2868b654562b158cee3fef2cc6924946e4f749db48e3
5
5
  SHA512:
6
- metadata.gz: cca7e40750a13a618bfa6e8bef1f5ac7ca0b4d2c16c38d11df6b699dddc6e22daa6b5dba62cdc850e1e18626a60e117210d416b118677cb09709ac1db62121d8
7
- data.tar.gz: 9d9fecc4df34a2d26ddb78e117ffbb6c98dca58b0651c7f75cce7fdffbc8885302b0c91d1fee67413ed2435ec6252a7941779f648ab3ba035e9bb5669ef94293
6
+ metadata.gz: 12f9c825656303da76046668bfe6981af48380b823059ea303bb131680e335396787c79058142b39759b341ca147ddc4b2e93d6c9fd0e7af890f37eaf6ee028b
7
+ data.tar.gz: 39d5008d3044eb9f1ba6190d73581b85a99859cef2b1cfa422f4e0226cc5247c5357956bcddc43c63af5fae4890a27f264acdc86c50f21c0ebed2f5a60592c09
@@ -1,3 +1,10 @@
1
+ # 0.0.5 (2020-06-14)
2
+
3
+ * Fix crash on suspended Launchpad user (@Photon89)
4
+ * Fix crash on comments above size limit by trancating them (@Photon89)
5
+ * Sort bug with respect to creation date (@Photon89)
6
+ * Set links to attachments (@Photon89)
7
+
1
8
  # 0.0.4 (2014-04-21)
2
9
 
3
10
  * Support multiple pages of launchpad bugs (@johnf)
data/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ # Project Status
2
+
3
+ All my projects have been on GitHub for a very long time, so I haven't personally used this tool in over two years. It really scratched a once off itch when I was moving some projects from LaunchPad.
4
+
5
+ While I probably won't do any work on it myself, I'm more than happy to take pull requests and I'll do releases based on those.
6
+
1
7
  # github-issue-importer
2
8
 
3
9
  Github Issue Importer imports bugs into github issues. Currently it only
data/TODO.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # TODO
2
2
 
3
- * Implement pagination so we can import more than 75 bugs
4
3
  * Support other bug trackers
5
4
  * Talk to github about being able to set other users somehow on the import.
6
5
  - Maybe allow anyone that is an owner of the project or something?
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'trollop'
3
+ require 'optimist'
4
4
  require 'octokit'
5
5
 
6
6
  require 'github-issue-importer'
@@ -14,7 +14,7 @@ unless nil.respond_to? :blank?
14
14
  end
15
15
  end
16
16
 
17
- options = Trollop::options do
17
+ options = Optimist::options do
18
18
  banner <<-EOS
19
19
  github-issue-importer imports bugs from a Launchpad project into github issues.
20
20
 
@@ -35,13 +35,13 @@ EOS
35
35
  opt :'gh-repo', 'Github repository (e.g. johnf/github-issue-importer)', :type => String
36
36
  end
37
37
 
38
- Trollop::die :'lp-project', "Please specify a Launchpad project" if options[:'lp-project'].nil?
39
- Trollop::die :'gh-login', "Please specify a GitHub login" if options[:'gh-login'].nil?
40
- Trollop::die :'gh-token', "Please specify a GitHub token" if options[:'gh-token'].nil?
41
- Trollop::die :'gh-repo', "Please specify a GitHub Repository" if options[:'gh-repo'].nil?
38
+ Optimist::die :'lp-project', "Please specify a Launchpad project" if options[:'lp-project'].nil?
39
+ Optimist::die :'gh-login', "Please specify a GitHub login" if options[:'gh-login'].nil?
40
+ Optimist::die :'gh-token', "Please specify a GitHub token" if options[:'gh-token'].nil?
41
+ Optimist::die :'gh-repo', "Please specify a GitHub Repository" if options[:'gh-repo'].nil?
42
42
 
43
43
  options[:'gh-repo-user'], options[:'gh-repo-name'] = options[:'gh-repo'].split('/')
44
- Trollop::die :'gh-repo', "Please specify a valid GitHub Repository" if options[:'gh-repo-user'].nil? or options[:'gh-repo-name'].nil?
44
+ Optimist::die :'gh-repo', "Please specify a valid GitHub Repository" if options[:'gh-repo-user'].nil? or options[:'gh-repo-name'].nil?
45
45
 
46
46
  gh_client = Octokit::Client.new :access_token => options[:'gh-token']
47
47
 
@@ -74,7 +74,7 @@ bug_entries.each do |bug_entry|
74
74
  bug_time = Time.parse(bug['date_created'])
75
75
 
76
76
  body = "#{bug['description']}\n\n"
77
- body += "Launchpad Details: [#LP#{bug['id']}](#{bug['web_link']}) #{bug_owner['display_name']} - #{bug_time}"
77
+ body += "Launchpad Details: [#LP#{bug['id']}](#{bug['web_link']}) #{bug_owner} - #{bug_time}"
78
78
 
79
79
  comments = launchpad.get_bug_comments bug
80
80
 
@@ -88,12 +88,17 @@ bug_entries.each do |bug_entry|
88
88
 
89
89
  comments.shift # First comment is always the bug description
90
90
  comments.each do |comment|
91
- next if comment['content'].blank?
92
91
  comment_owner = launchpad.get_owner comment
93
92
 
93
+ body = launchpad.get_comment_attachments comment
94
+
94
95
  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}"
96
+ body += "#{comment['content']}\n\n"
97
+ if body.size > 65000
98
+ puts "Comment body too long, truncating!"
99
+ body = body[0,65000] + "\n\n... (comment truncated because it was too long)\n\n"
100
+ end
101
+ body += "Launchpad Details: [#LPC#{comment['id']}](#{comment['web_link']}) #{comment_owner} - #{comment_time}"
97
102
 
98
103
  gh_client.add_comment gh_repo.full_name, issue.number, body
99
104
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.require_paths = ["lib"]
23
23
 
24
24
  s.add_dependency('octokit')
25
- s.add_dependency('trollop')
25
+ s.add_dependency('optimist')
26
26
 
27
27
  s.add_development_dependency('awesome_print')
28
28
  s.add_development_dependency('rake')
@@ -1,5 +1,6 @@
1
1
  require 'json'
2
- require 'open-uri'
2
+ require 'net/http'
3
+ require 'uri'
3
4
 
4
5
  module GithubIssueImporter
5
6
  class Launchpad
@@ -20,7 +21,7 @@ module GithubIssueImporter
20
21
  break unless url
21
22
  end
22
23
 
23
- entries
24
+ entries.sort_by! { |o| o['date_created'] }
24
25
  end
25
26
 
26
27
  def get_bug(id)
@@ -32,6 +33,19 @@ module GithubIssueImporter
32
33
  get bug_link
33
34
  end
34
35
 
36
+ def get_comment_attachments(comment)
37
+ comment_attachments_link = comment['bug_attachments_collection_link']
38
+ comment_attachments = get comment_attachments_link
39
+ body = ""
40
+ if !comment_attachments.nil?
41
+ comment_attachments['entries'].each do |attachment|
42
+ body += "Attachment: [#{attachment['title']}](#{attachment['data_link']})\n"
43
+ end
44
+ body += "\n"
45
+ end
46
+ return body
47
+ end
48
+
35
49
  def get_bug_comments(id)
36
50
  if id.is_a? Hash
37
51
  bug_comments_link = id['messages_collection_link']
@@ -50,14 +64,20 @@ module GithubIssueImporter
50
64
  end
51
65
 
52
66
  if @owners[owner_link].nil?
53
- @owners[owner_link] = get owner_link
67
+ response = Net::HTTP.get_response(URI.parse(owner_link)).body
68
+ if response.include? "User is suspended"
69
+ @owners[owner_link] = response[22,response.length].concat("suspended user'")
70
+ else
71
+ json = JSON.parse response
72
+ @owners[owner_link] = json['display_name']
73
+ end
54
74
  end
55
75
 
56
76
  @owners[owner_link]
57
77
  end
58
78
 
59
79
  def get(url)
60
- JSON.parse open(url).read
80
+ JSON.parse Net::HTTP.get_response(URI.parse(url)).body rescue nil
61
81
  end
62
82
 
63
83
  end
@@ -1,7 +1,7 @@
1
1
  module Github
2
2
  module Issue
3
3
  module Importer
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-issue-importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Ferlito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-21 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: trollop
28
+ name: optimist
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -105,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubyforge_project: github-issue-importer
109
- rubygems_version: 2.2.0
108
+ rubygems_version: 3.1.2
110
109
  signing_key:
111
110
  specification_version: 4
112
111
  summary: Launchpad to Github bug importer