git2bit 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +78 -23
- data/README.rdoc +15 -7
- data/bin/git2bit +11 -5
- data/lib/git2bit/github.rb +12 -6
- data/lib/git2bit/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,61 @@
|
|
1
1
|
# git2bit
|
2
2
|
|
3
|
-
There are many people out there that have migrated their private repositories from Github to
|
3
|
+
There are many people out there that have migrated their private repositories from Github to Bitbucket. Bitbucket has a goo utility that will clone your entire repository over, however, there is no way to migrate any existing issues that you have on Github.
|
4
4
|
|
5
|
-
git2bit is a CLI that solves this by migrating all your issues along with their comments and milestones from Github into your new
|
5
|
+
git2bit is a CLI that solves this by migrating all your issues along with their comments and milestones from Github into your new Bitbucket repo.
|
6
6
|
|
7
7
|
**Important Tip**: I recommend that you create a new blank repo in Bitbucket to run intial migration tests with. Once you are happy with the migration results, you can delete this repository and proceed with migrating issues to the production repo.
|
8
8
|
|
9
|
+
## How does it work?
|
10
|
+
|
11
|
+
The issues systems between Github and Bitbucket are similar but also pretty different. Github uses *labels* in order to get you to organize and categorize your issues. Bitbucket does not support labels and instead has a more traditional approach using a predefined set of fields.
|
12
|
+
|
13
|
+
Obviously the issue title and body will come over unchanged. However, all of the migrated issues will be created by the Bitbucket user account that is configred in git2bit. The original creation date of the issue will not be migrated either. As a consolation, the original data from Github will be inserted at the top of the newly created issue.
|
14
|
+
|
15
|
+
Github issue #459 created by joeworkman on 2012-09-06 20:51:49
|
16
|
+
|
17
|
+
Here are some more caveats with each Bitbucket issue field.
|
18
|
+
|
19
|
+
**Tip**: Chances are you already had labels in Github for organizing issues by kind, priority, or component. Before you migrate issues using git2bit, make sure that you rename your labels to maps to the supported Bitbucket fields documented below.
|
20
|
+
|
21
|
+
### Comments
|
22
|
+
|
23
|
+
The first comment added to newly created issues will contain a list of all the Github labels that were assigned to the original ticket. This will ensure that you still have this data if its valuable to you.
|
24
|
+
|
25
|
+
All comments from Github will be brought over and inserted into the new issue created on Bitbucket. Just like at the ticket level the creation data (username & date) will be inserted at the top of each comment.
|
26
|
+
|
27
|
+
### Kind
|
28
|
+
|
29
|
+
Bitbucket supports 4 different kinds of issues: `bug`, `enhancement`, `proposal`, and `task`.
|
30
|
+
|
31
|
+
git2bit will evaluate all of the labels that are assigned to each Github issue. If one of the labels matches the mentioned Bitbucket kinds, when the issue if created, it will be assigned to that kind. If no matching label is found, the issue will default to be a bug.
|
32
|
+
|
33
|
+
### Priority
|
34
|
+
|
35
|
+
Bitbucket supports 5 different priorities for issues: `trivial`, `minor`, `major`, `critical`, and `blocker`.
|
36
|
+
|
37
|
+
git2bit will evaluate all of the labels that are assigned to each Github issue. If one of the labels matches the mentioned Bitbucket priorities, when the issue if created, it will be assigned to that priority. If no matching label is found, the issue will default to the priority of trivial.
|
38
|
+
|
39
|
+
### Status
|
40
|
+
|
41
|
+
Bitbucket supports 7 different priorities for issues: `new`, `open`, `resolved`, `on hold`, `invalid`, `duplicate`, and `wontfix`.
|
42
|
+
|
43
|
+
This somewhat overlaps with Github issue status. In Github an issue can only ever be opened or closed. However, I know for a fact that developers use labels to get better fine-grained control over this. Therefore, git2bit evaluates the labels on each Github issue. If one of the labels matches the mentioned Bitbucket status options, when the issue if created, it will be assigned to that status. If no matching label is found, then the issue will be set to open.
|
44
|
+
|
45
|
+
**Note**: The `closed` status in a Github issue will trump everything. In this case, the newly created issue will be set to `resolved` in Bitbucket.
|
46
|
+
|
47
|
+
### Component
|
48
|
+
|
49
|
+
Bitbucket has support for manually defined components. If you would like for git2bit to populate this field for an issue, you will need to make sure that all of the Components are defined in your repository's Issues settings.
|
50
|
+
|
51
|
+
git2bit will evaluate all of the labels that are assigned to each Github issue. If one of the labels matches a preconfigured Component, the newly created issue will be assigned to that Component. If no matching label is found, no Components will be assigned.
|
52
|
+
|
53
|
+
**Note**: Bitbucket only allows an issue to be associated with one Component. Therefore, if you were using Github labels to assign multiple Components to an issue, when git2bit processes an issue, the first Component found within the labels wins.
|
54
|
+
|
55
|
+
### Milestone
|
56
|
+
|
57
|
+
git2bit will honor the assignment of an issue to a milestone. If a mielstone does not exist in Bitbucket, it will be created. This ensure that when the new issue is created, its properly associated with the same milestones as it was in Github.
|
58
|
+
|
9
59
|
## Installation
|
10
60
|
|
11
61
|
Install it via the gem command in terminal:
|
@@ -20,26 +70,24 @@ You can now execute it:
|
|
20
70
|
|
21
71
|
Here is an overview of the options available to git2bit along with some helpful examples. See below for how to set these values using a `.git2bit.rc` config file.
|
22
72
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
The following examples assume that you have the following options configured in your `.git2bit.rc` file: guser, gpass, grepo, buser, bpass, brepo
|
73
|
+
Usage: git2bit [options]
|
74
|
+
|
75
|
+
Options:
|
76
|
+
-h, --help Show command line help
|
77
|
+
--version Show help/version info
|
78
|
+
--[no-]closed [Do not] migrate closed issues
|
79
|
+
--issue ISSUE_NUMBER Process only a single Github issue number
|
80
|
+
--guser USER Github username
|
81
|
+
--gpass PASSWORD Github password
|
82
|
+
--grepo REPO Github repo name
|
83
|
+
--buser USER Bitbucket username
|
84
|
+
--bpass PASSWORD Bitbucket password
|
85
|
+
--brepo REPO Bitbucket repo name
|
86
|
+
--log-level LEVEL Set the logging level
|
87
|
+
(debug|info|warn|error|fatal)
|
88
|
+
(Default: info)
|
89
|
+
|
90
|
+
The following examples assume that you have the following options configured in your `.git2bit.rc` file: `guser`, `gpass`, `grepo`, `buser`, `bpass`, `brepo`
|
43
91
|
|
44
92
|
Move *all* issues (open and closed):
|
45
93
|
|
@@ -55,7 +103,7 @@ Move a single issue:
|
|
55
103
|
|
56
104
|
### .git2bit.rc
|
57
105
|
|
58
|
-
Instead of passing a ton of options via command line, you can setup the configuration values in a file named
|
106
|
+
Instead of passing a ton of options via command line, you can setup the configuration values in a file named `.git2bit.rc`. This file should live in your home directory.
|
59
107
|
|
60
108
|
Here is a sample file to get you going.
|
61
109
|
|
@@ -75,3 +123,10 @@ Here is a sample file to get you going.
|
|
75
123
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
124
|
4. Push to the branch (`git push origin my-new-feature`)
|
77
125
|
5. Create new Pull Request
|
126
|
+
|
127
|
+
## Thank You
|
128
|
+
|
129
|
+
git2bit uses the following awesome Ruby Gems:
|
130
|
+
|
131
|
+
* github_api - <https://github.com/peter-murach/github>
|
132
|
+
* bitbucket_rest_api - <https://github.com/exceptionary/bitbucket>
|
data/README.rdoc
CHANGED
@@ -1,19 +1,27 @@
|
|
1
|
-
= git2bit -
|
1
|
+
= git2bit - git2bit migrates issues with their comments and milestones from a github repo to a bitbucket repo
|
2
2
|
|
3
|
-
Author::
|
4
|
-
Copyright:: Copyright (c) 2013
|
3
|
+
Author:: Joe Workman (joe at workmanmail.com)
|
4
|
+
Copyright:: Copyright (c) 2013 Joe Workman
|
5
5
|
|
6
6
|
|
7
7
|
DESCRIBE YOUR GEM HERE
|
8
8
|
|
9
9
|
== Links
|
10
10
|
|
11
|
-
* {Source on
|
12
|
-
* RDoc[LINK TO RDOC.INFO]
|
11
|
+
* {Source on Bitbucket}[https://bitbucket.org/joeworkman/git2bit]
|
13
12
|
|
14
13
|
== Install
|
15
14
|
|
16
|
-
|
15
|
+
Install:
|
16
|
+
gem install git2bit
|
17
17
|
|
18
|
-
==
|
18
|
+
== Shell Examples
|
19
19
|
|
20
|
+
Move all issues (open and closed):
|
21
|
+
git2bit
|
22
|
+
|
23
|
+
Move only open issues:
|
24
|
+
git2bit --no-close
|
25
|
+
|
26
|
+
Move a single issue:
|
27
|
+
git2bit -i 532
|
data/bin/git2bit
CHANGED
@@ -22,7 +22,7 @@ class App
|
|
22
22
|
|
23
23
|
# Connect to Bitbucket and Github
|
24
24
|
bitbucket = Git2bit::BitbucketProxy.new({:user => options[:buser], :pass => options[:bpass],:repo => options[:brepo]})
|
25
|
-
github = Git2bit::GithubProxy.new({:user => options[:guser], :pass => options[:gpass], :repo => options[:grepo]})
|
25
|
+
github = Git2bit::GithubProxy.new({:user => options[:guser], :pass => options[:gpass], :org => options[:gorg], :repo => options[:grepo]})
|
26
26
|
|
27
27
|
if options[:issue]
|
28
28
|
info "Will only process Github issue ##{options[:issue]}"
|
@@ -35,8 +35,13 @@ class App
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Start processing each issue in Github
|
38
|
+
issues = Hash.new
|
38
39
|
github.each_issue(options[:closed]) { |issue|
|
39
|
-
|
40
|
+
issues.store(issue.number, issue)
|
41
|
+
}
|
42
|
+
|
43
|
+
issues.keys.sort.each { |key|
|
44
|
+
issue = issues[key]
|
40
45
|
# Go to the next iteration if the issue number does not match option provided
|
41
46
|
next if options[:issue] and options[:issue].to_i != issue.number
|
42
47
|
|
@@ -84,8 +89,8 @@ class App
|
|
84
89
|
# Add the comment into the newly created bitbucket issue
|
85
90
|
bitbucket.create_comment new_issue, "_Github comment by **#{comment.user.login}** on #{comment_date.strftime('%F %T')}_\n\n#{comment[:body]}"
|
86
91
|
end
|
87
|
-
end
|
88
|
-
}
|
92
|
+
end
|
93
|
+
}
|
89
94
|
info "Processing Complete."
|
90
95
|
end
|
91
96
|
|
@@ -101,7 +106,8 @@ class App
|
|
101
106
|
on("--guser USER","Github username")
|
102
107
|
on("--gpass PASSWORD","Github password")
|
103
108
|
on("--grepo REPO","Github repo name")
|
104
|
-
|
109
|
+
on("--gorg ORG", "Github Organization name for repos owned by Organizations")
|
110
|
+
|
105
111
|
on("--buser USER","BitBucket username")
|
106
112
|
on("--bpass PASSWORD","BitBucket password")
|
107
113
|
on("--brepo REPO","BitBucket repo name")
|
data/lib/git2bit/github.rb
CHANGED
@@ -10,21 +10,27 @@ module Git2bit
|
|
10
10
|
def initialize(args)
|
11
11
|
@repo = args[:repo]
|
12
12
|
@user = args[:user]
|
13
|
-
|
13
|
+
@org = args[:org]
|
14
|
+
if @org
|
15
|
+
@repo_owner = @org
|
16
|
+
else
|
17
|
+
@repo_owner = @user
|
18
|
+
end
|
19
|
+
begin
|
14
20
|
@conn = Github.new :basic_auth => "#{@user}:#{args[:pass]}"
|
15
21
|
@conn.repos.list user: @user
|
16
|
-
info "Successfully connected to Github #{@user}
|
22
|
+
info "Successfully connected to Github with user #{@user}"
|
17
23
|
rescue Exception => e
|
18
|
-
error = ["Error: Unable to connect to Github #{@user}
|
24
|
+
error = ["Error: Unable to connect to Github with user #{@user}", e.message].push e.backtrace
|
19
25
|
exit_now!(error.join("\n"))
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
23
29
|
def each_issue(process_closed = true)
|
24
30
|
data = Array.new
|
25
|
-
data.push @conn.issues.list :filter => 'all', :state => 'open', :user => @
|
31
|
+
data.push @conn.issues.list :filter => 'all', :state => 'open', :user => @repo_owner, :repo => @repo
|
26
32
|
if process_closed
|
27
|
-
data.push @conn.issues.list :filter => 'all', :state => 'closed', :user => @
|
33
|
+
data.push @conn.issues.list :filter => 'all', :state => 'closed', :user => @repo_owner, :repo => @repo
|
28
34
|
end
|
29
35
|
|
30
36
|
data.each do |result_set|
|
@@ -37,7 +43,7 @@ module Git2bit
|
|
37
43
|
def get_comments(issue_id)
|
38
44
|
begin
|
39
45
|
# Get Github comments for issue ID
|
40
|
-
comments = @conn.issues.comments.all @
|
46
|
+
comments = @conn.issues.comments.all @repo_owner, @repo, issue_id: issue_id
|
41
47
|
debug "Github: got comments for issue ##{issue_id}: " + comments.inspect
|
42
48
|
rescue Exception => e
|
43
49
|
error "Error: Unable to get comments for Github issue ##{issue_id} - " + e.message
|
data/lib/git2bit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git2bit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
segments:
|
150
150
|
- 0
|
151
|
-
hash: -
|
151
|
+
hash: -3228153391256863325
|
152
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
153
|
none: false
|
154
154
|
requirements:
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
segments:
|
159
159
|
- 0
|
160
|
-
hash: -
|
160
|
+
hash: -3228153391256863325
|
161
161
|
requirements: []
|
162
162
|
rubyforge_project:
|
163
163
|
rubygems_version: 1.8.24
|