github-issue-importer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/TODO.md +6 -0
- data/bin/github-issue-importer +95 -0
- data/github-issue-importer.gemspec +26 -0
- data/lib/github-issue-importer/launchpad.rb +55 -0
- data/lib/github-issue-importer/version.rb +7 -0
- data/lib/github-issue-importer.rb +2 -0
- metadata +99 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 John Ferlito.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# github-issue-importer
|
2
|
+
|
3
|
+
Github Issue Importer imports bugs into github issues. Currently it only
|
4
|
+
supports Launchpad. It is hoped it will support other bug trackers in the
|
5
|
+
future.
|
6
|
+
|
7
|
+
The importer will import each bug and it's comments into github. It uses the
|
8
|
+
following algorithm for Launchpad.
|
9
|
+
|
10
|
+
* Ignore the first comment as it holds the original description
|
11
|
+
* Set the Importance as a label
|
12
|
+
* Close the bug if it is in Fix Released or Fix Committed state.
|
13
|
+
* Add a one line summary to the end of the bug and comments with link to
|
14
|
+
Launchpad and who the original author was.
|
15
|
+
|
16
|
+
Instructions
|
17
|
+
------------
|
18
|
+
|
19
|
+
First install them gem.
|
20
|
+
|
21
|
+
gem install github-issue-importer
|
22
|
+
|
23
|
+
To import into github, you will need a public github repository with issues
|
24
|
+
enabled. You will also need the github API token for your account which can be
|
25
|
+
found on the [Account Admin Page](https://github.com/account/admin).
|
26
|
+
|
27
|
+
You can then import a project like so
|
28
|
+
|
29
|
+
github-issue-importer --lp-project zookeepr --gh-login johnf --gh-token TOKEN --gh-repo johnf/test
|
30
|
+
|
31
|
+
## Note on Patches/Pull Requests
|
32
|
+
|
33
|
+
* Fork the project on github.
|
34
|
+
* Make your feature addition or bug fix.
|
35
|
+
* Add tests for it. This is important so I don't break it in a
|
36
|
+
future version unintentionally.
|
37
|
+
* Commit, do not mess with Rakefile, version, or history.
|
38
|
+
(if you want to have your own version, that is fine but bump version in a
|
39
|
+
commit by itself I can ignore when I pull)
|
40
|
+
* Send me a pull request. Bonus points for topic branches.
|
41
|
+
|
42
|
+
## Licensing
|
43
|
+
|
44
|
+
github Issue Importer is MIT licensed.
|
data/Rakefile
ADDED
data/TODO.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'trollop'
|
4
|
+
require 'octopi'
|
5
|
+
|
6
|
+
require 'github-issue-importer'
|
7
|
+
|
8
|
+
|
9
|
+
options = Trollop::options do
|
10
|
+
banner <<-EOS
|
11
|
+
github-issue-importer imports bugs from a Launchpad project into github issues.
|
12
|
+
|
13
|
+
Usage:
|
14
|
+
github-issue-importer [OPTIONS]
|
15
|
+
|
16
|
+
Example:
|
17
|
+
|
18
|
+
github-issue-importer --lp-project zookeepr \\
|
19
|
+
--gh-login johnf \\
|
20
|
+
--gh-token 823dadlknf8 \\
|
21
|
+
--gh-repo johnf/zookeepr
|
22
|
+
|
23
|
+
EOS
|
24
|
+
opt :'lp-project', 'Launchpad project', :type => String
|
25
|
+
opt :'gh-login', 'Github user to login as', :type => String
|
26
|
+
opt :'gh-token', 'Github API token', :type => String
|
27
|
+
opt :'gh-repo', 'Github repository (e.g. johnf/github-issue-importer)', :type => String
|
28
|
+
end
|
29
|
+
|
30
|
+
Trollop::die :'lp-project', "Please specify a Launchpad project" if options[:'lp-project'].nil?
|
31
|
+
Trollop::die :'gh-login', "Please specify a GitHub login" if options[:'gh-login'].nil?
|
32
|
+
Trollop::die :'gh-token', "Please specify a GitHub token" if options[:'gh-token'].nil?
|
33
|
+
Trollop::die :'gh-repo', "Please specify a GitHub Repository" if options[:'gh-repo'].nil?
|
34
|
+
|
35
|
+
options[:'gh-repo-user'], options[:'gh-repo-name'] = options[:'gh-repo'].split('/')
|
36
|
+
Trollop::die :'gh-repo', "Please specify a valid GitHub Repository" if options[:'gh-repo-user'].nil? or options[:'gh-repo-name'].nil?
|
37
|
+
|
38
|
+
include Octopi
|
39
|
+
|
40
|
+
begin
|
41
|
+
gh_user = Octopi::User.find options[:'gh-repo-user']
|
42
|
+
rescue Octopi::NotFound
|
43
|
+
$stderr.puts "Could not find the user #{options[:'gh-repo-user']} in the repo name it is either private or doesn't exist"
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
begin
|
48
|
+
gh_repo = gh_user.repository options[:'gh-repo-name']
|
49
|
+
rescue Octopi::NotFound
|
50
|
+
$stderr.puts "The user #{options[:'gh-repo-user']} doesn't have a repository named #{options[:'gh-repo-name']} or it is private"
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
launchpad = GithubIssueImporter::Launchpad.new
|
55
|
+
|
56
|
+
bug_entries = launchpad.get_bug_entries options[:'lp-project']
|
57
|
+
bug_entries.each do |bug_entry|
|
58
|
+
|
59
|
+
bug = launchpad.get_bug bug_entry
|
60
|
+
puts "Processing Bug #{bug['id']}"
|
61
|
+
|
62
|
+
bug_owner = launchpad.get_owner bug
|
63
|
+
bug_time = Time.parse(bug['date_created'])
|
64
|
+
|
65
|
+
body = "#{bug['description']}\n\n"
|
66
|
+
body += "Launchpad Details: [#LP#{bug['id']}](#{bug['web_link']}) #{bug_owner['display_name']} - #{bug_time}"
|
67
|
+
|
68
|
+
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
|
+
|
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
|
76
|
+
|
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}"
|
80
|
+
|
81
|
+
issue.comment body
|
82
|
+
end
|
83
|
+
|
84
|
+
bug_status = bug_entry['status']
|
85
|
+
if bug_status =~ /^Fix/
|
86
|
+
issue.close!
|
87
|
+
end
|
88
|
+
|
89
|
+
bug_importance = bug_entry['importance']
|
90
|
+
unless bug_importance.blank? or bug_importance == 'Undecided'
|
91
|
+
issue.add_label bug_importance.downcase
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "github-issue-importer/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "github-issue-importer"
|
7
|
+
s.version = Github::Issue::Importer::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['John Ferlito']
|
10
|
+
s.email = ['johnf@inodes.org']
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Launchpad to Github bug importer}
|
13
|
+
s.description = %q{Migrate bugs from a Launchpas project into Github Issues}
|
14
|
+
|
15
|
+
s.rubyforge_project = "github-issue-importer"
|
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.add_dependency('octopi')
|
23
|
+
s.add_dependency('trollop')
|
24
|
+
|
25
|
+
s.add_development_dependency('awesome_print')
|
26
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module GithubIssueImporter
|
5
|
+
class Launchpad
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@owners = Hash.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_bug_entries(project)
|
12
|
+
bugs = get "https://api.launchpad.net/1.0/#{project}?ws.op=searchTasks"
|
13
|
+
bugs['entries']
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_bug(id)
|
17
|
+
if id.is_a? Hash
|
18
|
+
bug_link = id['bug_link']
|
19
|
+
else
|
20
|
+
bug_link = "https://api.launchpad.net/1.0/bugs/#{id}"
|
21
|
+
end
|
22
|
+
get bug_link
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_bug_comments(id)
|
26
|
+
if id.is_a? Hash
|
27
|
+
bug_comments_link = id['messages_collection_link']
|
28
|
+
else
|
29
|
+
bug_comments_link = "https://api.launchpad.net/1.0/bugs/#{id}/comments"
|
30
|
+
end
|
31
|
+
comments = get bug_comments_link
|
32
|
+
comments['entries']
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_owner(id)
|
36
|
+
if id.is_a? Hash
|
37
|
+
owner_link = id['owner_link']
|
38
|
+
else
|
39
|
+
owner_link = "https://api.launchpad.net/1.0/~#{id}"
|
40
|
+
end
|
41
|
+
|
42
|
+
if @owners[owner_link].nil?
|
43
|
+
@owners[owner_link] = get owner_link
|
44
|
+
end
|
45
|
+
|
46
|
+
@owners[owner_link]
|
47
|
+
end
|
48
|
+
|
49
|
+
def get(url)
|
50
|
+
JSON.parse open(url).read
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github-issue-importer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Ferlito
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
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:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: trollop
|
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: awesome_print
|
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: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
description: Migrate bugs from a Launchpas project into Github Issues
|
50
|
+
email:
|
51
|
+
- johnf@inodes.org
|
52
|
+
executables:
|
53
|
+
- github-issue-importer
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- Gemfile
|
61
|
+
- LICENSE
|
62
|
+
- README.md
|
63
|
+
- Rakefile
|
64
|
+
- TODO.md
|
65
|
+
- bin/github-issue-importer
|
66
|
+
- github-issue-importer.gemspec
|
67
|
+
- lib/github-issue-importer.rb
|
68
|
+
- lib/github-issue-importer/launchpad.rb
|
69
|
+
- lib/github-issue-importer/version.rb
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: ""
|
72
|
+
licenses: []
|
73
|
+
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project: github-issue-importer
|
94
|
+
rubygems_version: 1.5.0
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Launchpad to Github bug importer
|
98
|
+
test_files: []
|
99
|
+
|