lab2hub 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8de7a06271a4657d2c9f3f3a74fd891ee3a81af
4
+ data.tar.gz: 9f6c3edb0a74e119023c2a1ded36b637765ade92
5
+ SHA512:
6
+ metadata.gz: 038a4c668b19d4552889154697000b77e00f4b7a09688ba9dbec93791a33e0df75a84330e9778daa30844e11bef7586ca1cbf7927094978b441424c061816d61
7
+ data.tar.gz: 94e06897a386ed0cd8a7b64a582e93940a2544e7a007cd280cc359cb3562783d14047dc1c9ccb4a8f0198792a40d63c844fc3a8e79e17cfe308cb039fd3c038b
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ config.yaml
11
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lab2hub.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 buo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Lab2hub
2
+
3
+ Easily migrate your projects from GitLab to GitHub.
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ gem install lab2hub
9
+ lab2hub --config
10
+ vi config.yaml
11
+ lab2hub PROJECT_NAME_ON_GITLAB
12
+ ```
13
+
14
+ ## Development
15
+
16
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
17
+
18
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
19
+
20
+ ## Contributing
21
+
22
+ Bug reports and pull requests are welcome on GitHub at https://github.com/buo/lab2hub.
23
+
24
+ ## License
25
+
26
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lab2hub"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/lab2hub ADDED
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'github_api'
4
+ require 'gitlab'
5
+ require 'optparse'
6
+ require 'pp'
7
+ require 'yaml'
8
+
9
+ # This hash will hold all of the options parsed from the command-line by
10
+ # OptionParser.
11
+ options = {}
12
+
13
+ optparse = OptionParser.new do |opts|
14
+ # Set a banner, displayed at the top of the help screen.
15
+ opts.banner = "Usage: lab2hub [options] PROJECT"
16
+
17
+ opts.on('--config', 'Create a config file in the working directory.') do
18
+ options[:config] = true
19
+ end
20
+
21
+ # This displays the help screen, all programs are assumed to have this option.
22
+ opts.on('-h', '--help', 'Display this screen.') do
23
+ puts opts
24
+ exit
25
+ end
26
+ end
27
+
28
+ # Parse the command-line.
29
+ optparse.parse!
30
+
31
+ if options[:config]
32
+ src = File.expand_path('../../tools/config.example.yaml', __FILE__)
33
+ dst = 'config.yaml'
34
+
35
+ if File.exists? src
36
+ puts 'already exists.'
37
+ exit
38
+ end
39
+
40
+ FileUtils.cp src, dst
41
+ puts 'created config.yaml'
42
+
43
+ exit
44
+ end
45
+
46
+ config = YAML::load(File.open('config.yaml'))
47
+
48
+ github = Github.new oauth_token: config["github"]
49
+ Gitlab.configure do |gitlab|
50
+ gitlab.endpoint = 'https://gitlab.com/api/v3'
51
+ gitlab.private_token = config["gitlab"]
52
+ end
53
+
54
+ target = ARGV.first
55
+
56
+ unless target
57
+ puts 'Specify the project name to migrate'
58
+ exit
59
+ end
60
+
61
+ # Retrieve all projects
62
+ project = Gitlab.projects.auto_paginate.select do |item|
63
+ item.name == target
64
+ end.first
65
+
66
+ unless project
67
+ puts "Could not find the #{target} on GitLab"
68
+ exit
69
+ end
70
+
71
+ pp project
72
+
73
+ begin
74
+ repo = github.repos.create({
75
+ name: project.name,
76
+ description: project.description,
77
+ private: !project.public
78
+ })
79
+ puts repo
80
+
81
+ # Clone repository
82
+ cmd = File.expand_path('../../tools/migrate.sh', __FILE__)
83
+ arg1 = project.name
84
+ arg2 = project.ssh_url_to_repo
85
+ arg3 = repo.ssh_url
86
+ puts %x(#{cmd} "#{arg1}" "#{arg2}" "#{arg3}")
87
+
88
+ # Migrate issues
89
+ Gitlab.issues(project.id).auto_paginate.each do |issue|
90
+ puts '-' * 80
91
+ pp issue
92
+ created = github.issues.create({
93
+ user: repo.owner.login,
94
+ repo: repo.name,
95
+ title: issue.title,
96
+ body: issue.description,
97
+ labels: issue.labels
98
+ })
99
+ pp created
100
+ if issue.state == 'closed'
101
+ github.issues.edit({
102
+ user: repo.owner.login,
103
+ repo: repo.name,
104
+ number: created.number,
105
+ state: 'closed'
106
+ })
107
+ end
108
+ end
109
+ rescue Github::Error::UnprocessableEntity => e
110
+ puts e
111
+ end
data/lab2hub.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lab2hub/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lab2hub"
8
+ spec.version = Lab2hub::VERSION
9
+ spec.authors = ["buo"]
10
+ spec.email = ["buo@users.noreply.github.com"]
11
+
12
+ spec.summary = %q{Easily migrate your projects from GitLab to GitHub.}
13
+ spec.description = %q{lab2hub helps you migrate your projects from GitLab to GitHub easily.}
14
+ spec.homepage = "https://github.com/buo/lab2hub"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "github_api", "~> 0.14"
26
+ spec.add_development_dependency "gitlab", "~> 3.6"
27
+ end
@@ -0,0 +1,3 @@
1
+ module Lab2hub
2
+ VERSION = "0.1.0"
3
+ end
data/lib/lab2hub.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "lab2hub/version"
2
+
3
+ module Lab2hub
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,2 @@
1
+ github: GITHUB_PERSONAL_ACCESS_TOKEN
2
+ gitlab: GITLAB_PRIVATE_TOKEN
data/tools/migrate.sh ADDED
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ if [ $# -lt 3 ]; then
6
+ echo 'failed'
7
+ exit 1
8
+ fi
9
+
10
+ # Assume we are in your home directory
11
+ # cd ~/
12
+
13
+ # Clone the repo from GitLab using the `--mirror` option
14
+ git clone --mirror "$2"
15
+
16
+ # Change into newly created repo directory
17
+ cd $1.git
18
+
19
+ # Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
20
+ git push --no-verify --mirror "$3"
21
+
22
+ # Set push URL to the mirror location
23
+ git remote set-url --push origin "$3"
24
+
25
+ # To periodically update the repo on GitHub with what you have in GitLab
26
+ git fetch -p origin
27
+ git push --no-verify --mirror
28
+
29
+ # Clean
30
+ cd -
31
+ rm -rf $1.git
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lab2hub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - buo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: github_api
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: gitlab
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.6'
83
+ description: lab2hub helps you migrate your projects from GitLab to GitHub easily.
84
+ email:
85
+ - buo@users.noreply.github.com
86
+ executables:
87
+ - lab2hub
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - exe/lab2hub
101
+ - lab2hub.gemspec
102
+ - lib/lab2hub.rb
103
+ - lib/lab2hub/version.rb
104
+ - tools/config.example.yaml
105
+ - tools/migrate.sh
106
+ homepage: https://github.com/buo/lab2hub
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.5.0
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Easily migrate your projects from GitLab to GitHub.
130
+ test_files: []