gitlab_clone 0.10.2 → 0.11.0
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 +4 -4
- data/README.md +11 -8
- data/bin/gitlab-clone +45 -21
- data/changelog +6 -0
- data/gitlab_clone.gemspec +4 -4
- data/lib/github.rb +60 -0
- data/lib/jtc.rb +3 -1
- data/lib/version +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b686f239af7b5d292a611131cde594fcf4023847
|
4
|
+
data.tar.gz: 69d2bc76b3ce7ff94a8def56b53d56b2ad15c35a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d63b56b63a9670eb9b8a1bdf284d5cf32bf0bfe2d8b19e0e33a480a0bc98c11e5d4a5e391cbdf25e4ed6a8e463b610c2b4e910469b3e32593e6a73394284b34
|
7
|
+
data.tar.gz: de38d3fbb917d5cacddad5a67892c93effeddc4a1e9d8aaa5e0887dc5915fa478f49d3ecf7ec5fb91a958eac3b7ce40d87259b37fd5e22c8d23c0075f3ecd87b
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
# gitlab_clone
|
1
|
+
# gitlab_clone [](http://badge.fury.io/rb/gitlab_clone)
|
2
2
|
|
3
3
|
## Description
|
4
|
-
gitlab_clone allows you to clone repositories from a gitlab
|
4
|
+
gitlab_clone allows you to clone repositories from a gitlab server's group using the gitlab api.
|
5
|
+
|
6
|
+
The itch I was scratching by writing this was that I was writing cookbooks for home and work. I wanted an easier way to download all of my cookbooks so that I could work with all of them at once and not have to break my flow by having to download depended cookbooks later. Anyone that has worked with chef knows that you can have a lot of repos comporising all of your cookbooks...
|
5
7
|
|
6
8
|
## Features
|
7
9
|
gitlab_clone currently features the following:
|
@@ -10,13 +12,13 @@ gitlab_clone currently features the following:
|
|
10
12
|
* Can pick what group you can download all the repos in that group from.
|
11
13
|
* Will do a git pull if an existing repo has been detected.
|
12
14
|
* Support for using either ssh or the web url to download.
|
13
|
-
* List the repos in a group.
|
15
|
+
* List the repos in a group before cloning them.
|
14
16
|
|
15
17
|
## Examples
|
16
18
|
### Get a list of repos in a group named Home:
|
17
|
-
|
19
|
+
gitlab-clone -l -g Home
|
18
20
|
|
19
|
-
|
21
|
+
\-------------------------------------------------------------------
|
20
22
|
|
21
23
|
|
22
24
|
The following 3 repo(s) were found in the group Home.
|
@@ -28,14 +30,14 @@ gitlab_clone currently features the following:
|
|
28
30
|
\-------------------------------------------------------------------
|
29
31
|
|
30
32
|
### Clone the repos in the group named Home:
|
31
|
-
|
33
|
+
gitlab-clone -w -g Home
|
32
34
|
|
33
35
|
\-------------------------------------------------------------------
|
34
36
|
|
35
37
|
|
36
38
|
### Starting Web Clone Process Of The Group Home ###
|
37
39
|
|
38
|
-
Downloading 3 repo(s) into [HOME_DIR]/projects/
|
40
|
+
Downloading 3 repo(s) into [HOME_DIR]/projects/Home
|
39
41
|
|
40
42
|
Repo1 directory exists, doing a git pull instead.
|
41
43
|
Cloning Repo2...
|
@@ -46,4 +48,5 @@ gitlab_clone currently features the following:
|
|
46
48
|
|
47
49
|
## Installation
|
48
50
|
|
49
|
-
gem install gitlab_clone
|
51
|
+
gem install gitlab_clone
|
52
|
+
Will give you a command named gitlab-clone to use.
|
data/bin/gitlab-clone
CHANGED
@@ -5,30 +5,44 @@ require "json"
|
|
5
5
|
require "fileutils"
|
6
6
|
require "git"
|
7
7
|
require "jtc"
|
8
|
+
require "github"
|
8
9
|
require "version"
|
9
10
|
require "slop"
|
10
11
|
require "httparty"
|
11
12
|
|
12
|
-
# Check to see if we have vars set in envs and alert if we don't have them set...
|
13
13
|
|
14
|
+
opts = Slop.parse do
|
15
|
+
on :h, :help, 'help'
|
16
|
+
on :c, :clone, 'clone'
|
17
|
+
on :w, :web, 'web'
|
18
|
+
on :l, :list, 'list'
|
19
|
+
on :v, :version, 'version'
|
20
|
+
on :g, :group=, 'group'
|
21
|
+
on :o, :github, 'github'
|
22
|
+
end
|
23
|
+
|
24
|
+
if (opts[:v] && !ENV['gitlab_server'] && !ENV['gitlab_token']) || (opts[:o] && opts[:v] && !ENV['github_token'])
|
25
|
+
Jtc.version
|
26
|
+
end
|
14
27
|
|
28
|
+
# Check to see if we have vars set in envs and alert if we don't have them set...
|
15
29
|
unless ENV['gitlab_server'] && ENV['gitlab_token']
|
16
30
|
puts "-----------------------------------------------------------\n\n"
|
17
|
-
puts "You need to set the environment vars first before proceeding"
|
18
|
-
puts "
|
31
|
+
puts "You need to set the environment vars first before proceeding."
|
32
|
+
puts "For gitlab_token and gitlab_server in order to run gitlab-clone.\n\n"
|
19
33
|
puts " example: export gitlab_server=\"http[s]://[server_name]/api/v3\""
|
20
34
|
puts " export gitlab_token=\"secret_token\"\n\n"
|
21
35
|
puts "-----------------------------------------------------------\n"
|
22
36
|
exit
|
23
37
|
end
|
24
38
|
|
25
|
-
opts
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
39
|
+
if opts[:o] && !ENV['github_token']
|
40
|
+
puts "-----------------------------------------------------------\n\n"
|
41
|
+
puts "You need to set the environment vars first before proceeding"
|
42
|
+
puts "For Github support you need to add your Github token.\n\n"
|
43
|
+
puts " example: export github_token=\"secret_token\"\n\n"
|
44
|
+
puts "-----------------------------------------------------------\n"
|
45
|
+
exit
|
32
46
|
end
|
33
47
|
|
34
48
|
if ARGV[0].nil?
|
@@ -47,19 +61,29 @@ else
|
|
47
61
|
|
48
62
|
if opts[:g]
|
49
63
|
clone_group = opts[:g]
|
50
|
-
|
64
|
+
elsif opts[:l] || opts[:o] || opts[:w] || opts[:c]
|
65
|
+
puts "No organizational or group name was given using default of \"Cookbooks\"\n\n"
|
51
66
|
clone_group = "Cookbooks"
|
52
67
|
end
|
53
68
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
69
|
+
|
70
|
+
if opts[:o]
|
71
|
+
class_to_use = Github
|
72
|
+
else
|
73
|
+
class_to_use = Jtc
|
74
|
+
end
|
75
|
+
|
76
|
+
if opts[:h]
|
77
|
+
Jtc.printhelp
|
78
|
+
elsif opts[:c]
|
79
|
+
class_to_use.clone(0, clone_group)
|
80
|
+
elsif opts[:w]
|
81
|
+
class_to_use.clone(1, clone_group)
|
82
|
+
elsif opts[:v]
|
83
|
+
Jtc.version
|
84
|
+
elsif opts[:l]
|
85
|
+
class_to_use.list_repos(clone_group)
|
64
86
|
end
|
65
87
|
end
|
88
|
+
|
89
|
+
|
data/changelog
ADDED
data/gitlab_clone.gemspec
CHANGED
@@ -5,9 +5,9 @@ require 'version'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'gitlab_clone'
|
7
7
|
s.version = Version::VERSION
|
8
|
-
s.date = '2015-01-
|
9
|
-
s.summary = "Pulls down the latest repos from a group in gitlab."
|
10
|
-
s.description = "Clones All Repos In A Gitlab Group."
|
8
|
+
s.date = '2015-01-24'
|
9
|
+
s.summary = "Pulls down the latest repos from a group in gitlab or a organization group in Github."
|
10
|
+
s.description = "Clones All Repos In A Gitlab Group Or Github Org."
|
11
11
|
s.authors = ["Nestor N. Camacho III"]
|
12
12
|
s.email = 'ncamacho@nnc3.com.to'
|
13
13
|
s.files = `git ls-files`.split($/)
|
@@ -16,6 +16,6 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.add_dependency("slop", "~> 3.5.0")
|
17
17
|
s.add_dependency("httparty", "~> 0.13.1")
|
18
18
|
s.homepage =
|
19
|
-
'https://
|
19
|
+
'https://github.com/ncamacho/gitlab_clone'
|
20
20
|
s.license = 'MIT'
|
21
21
|
end
|
data/lib/github.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
class Github
|
2
|
+
TOKEN=ENV['github_token']
|
3
|
+
SERVER="https://api.github.com"
|
4
|
+
HOME=ENV['HOME']
|
5
|
+
|
6
|
+
|
7
|
+
def self.list_repos(group_name)
|
8
|
+
repos_list = get_repos(group_name)
|
9
|
+
puts "-------------------------------------------------------------------\n"
|
10
|
+
puts "\tThe following #{repos_list.count} repo(s) were found in the Org #{group_name}.\n\n"
|
11
|
+
repos_list.each do |get|
|
12
|
+
puts "\t\t#{get["name"]}"
|
13
|
+
end
|
14
|
+
puts "\n-------------------------------------------------------------------"
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def self.clone(web, group_name)
|
19
|
+
repos_list = get_repos(group_name)
|
20
|
+
repos_dir = "#{HOME}/projects/#{group_name}"
|
21
|
+
|
22
|
+
if File.directory?("#{repos_dir}")
|
23
|
+
FileUtils::mkdir_p repos_dir
|
24
|
+
end
|
25
|
+
|
26
|
+
if web == 1
|
27
|
+
repo_location = 'clone_url'
|
28
|
+
message = "Web"
|
29
|
+
else
|
30
|
+
repo_location = 'ssh_url'
|
31
|
+
message = "Ssh"
|
32
|
+
end
|
33
|
+
puts "-------------------------------------------------------------------\n"
|
34
|
+
puts "\t### Starting #{message} Clone Process Of The Org #{group_name} ###\n\n"
|
35
|
+
puts "\tDownloading #{repos_list.count} repo(s) into #{repos_dir}\n\n"
|
36
|
+
|
37
|
+
repos_list.each do |get|
|
38
|
+
repo_name = get["name"]
|
39
|
+
repo = get["#{repo_location}"]
|
40
|
+
dir = get["name"]
|
41
|
+
repo_dir = "#{repos_dir}/#{dir}"
|
42
|
+
|
43
|
+
if File.directory?("#{repo_dir}")
|
44
|
+
puts "\t#{repo_name} directory exists, doing a git pull instead."
|
45
|
+
Dir.chdir("#{repo_dir}")
|
46
|
+
g = Git.init
|
47
|
+
g.pull
|
48
|
+
else
|
49
|
+
puts "\tCloning #{repo_name}..."
|
50
|
+
Git.clone("#{repo}", "#{repo_dir}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
puts "-------------------------------------------------------------------\n"
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.get_repos(group_name)
|
57
|
+
string = HTTParty.get("#{SERVER}/orgs/#{group_name}/repos", :headers => {"Authorization" => "token #{TOKEN}", 'User-Agent' => 'HTTParty'}, :verify => false).to_json
|
58
|
+
rep = JSON.parse(string)
|
59
|
+
end
|
60
|
+
end
|
data/lib/jtc.rb
CHANGED
@@ -13,10 +13,12 @@ class Jtc
|
|
13
13
|
puts "\t-g, --group: will let you choose which gitlab group to look for repos in"
|
14
14
|
puts "\t-l, --list: will give you a list of repos in git\n\n"
|
15
15
|
puts "\t-w, --web: will clone using web protocol instead of ssh"
|
16
|
+
puts "\t-o, --github: will use Github instead of Gitlab for git server."
|
16
17
|
|
17
|
-
puts "\t NOTE: You need to set gitlab_server and gitlab_token for this to work."
|
18
|
+
puts "\t NOTE: You need to set gitlab_server and gitlab_token or github_token for this to work."
|
18
19
|
puts "\t\texample: export gitlab_server=\"http[s]://[server_name]/api/v3\""
|
19
20
|
puts "\t\t\t export gitlab_token=\"secret_token\""
|
21
|
+
puts "\t\t\t export github_token=\"secret_token\""
|
20
22
|
puts "-------------------------------------------------------------------\n\n"
|
21
23
|
end
|
22
24
|
|
data/lib/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.11.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab_clone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nestor N. Camacho III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.13.1
|
55
|
-
description: Clones All Repos In A Gitlab Group.
|
55
|
+
description: Clones All Repos In A Gitlab Group Or Github Org.
|
56
56
|
email: ncamacho@nnc3.com.to
|
57
57
|
executables:
|
58
58
|
- gitlab-clone
|
@@ -61,11 +61,13 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- README.md
|
63
63
|
- bin/gitlab-clone
|
64
|
+
- changelog
|
64
65
|
- gitlab_clone.gemspec
|
66
|
+
- lib/github.rb
|
65
67
|
- lib/jtc.rb
|
66
68
|
- lib/version
|
67
69
|
- lib/version.rb
|
68
|
-
homepage: https://
|
70
|
+
homepage: https://github.com/ncamacho/gitlab_clone
|
69
71
|
licenses:
|
70
72
|
- MIT
|
71
73
|
metadata: {}
|
@@ -88,5 +90,6 @@ rubyforge_project:
|
|
88
90
|
rubygems_version: 2.2.2
|
89
91
|
signing_key:
|
90
92
|
specification_version: 4
|
91
|
-
summary: Pulls down the latest repos from a group in gitlab
|
93
|
+
summary: Pulls down the latest repos from a group in gitlab or a organization group
|
94
|
+
in Github.
|
92
95
|
test_files: []
|