codebase 3.1.3 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/codebase/command.rb +6 -0
- data/lib/codebase/commands/clone.rb +55 -0
- metadata +12 -1
data/lib/codebase/command.rb
CHANGED
@@ -2,6 +2,7 @@ require 'codebase/commands/launchers'
|
|
2
2
|
require 'codebase/commands/branches'
|
3
3
|
require 'codebase/commands/setup'
|
4
4
|
require 'codebase/commands/deployments'
|
5
|
+
require 'codebase/commands/clone'
|
5
6
|
|
6
7
|
module Codebase
|
7
8
|
class Command
|
@@ -10,6 +11,7 @@ module Codebase
|
|
10
11
|
include Codebase::Commands::Branches
|
11
12
|
include Codebase::Commands::Setup
|
12
13
|
include Codebase::Commands::Deployments
|
14
|
+
include Codebase::Commands::Clone
|
13
15
|
|
14
16
|
attr_reader :directory, :args
|
15
17
|
|
@@ -79,5 +81,9 @@ module Codebase
|
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
84
|
+
def api(path, data = nil)
|
85
|
+
api_request("http://#{directory.domain}/#{path}", git_config_variable(:username), git_config_variable(:apikey), data)
|
86
|
+
end
|
87
|
+
|
82
88
|
end
|
83
89
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Codebase
|
2
|
+
module Commands
|
3
|
+
module Clone
|
4
|
+
|
5
|
+
require 'xmlsimple'
|
6
|
+
require 'highline/import'
|
7
|
+
HighLine.track_eof = false
|
8
|
+
|
9
|
+
def clone
|
10
|
+
projects = XmlSimple.xml_in(api('projects'))
|
11
|
+
projects = projects['project'].select{|p| p["status"].first == 'active'}
|
12
|
+
|
13
|
+
## Please somebody tell me there is a better way to do this using highline...
|
14
|
+
project_hash = {}
|
15
|
+
project_id = choose do |menu|
|
16
|
+
menu.select_by = :index
|
17
|
+
menu.prompt = "Please select a project: "
|
18
|
+
count = 0
|
19
|
+
for project in projects
|
20
|
+
project_hash[project['name'].first] = project['permalink'].first
|
21
|
+
menu.choice(project['name'].first)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
project = project_hash[project_id]
|
26
|
+
|
27
|
+
repositories = XmlSimple.xml_in(api("#{project}/repositories"))
|
28
|
+
repositories = repositories['repository']
|
29
|
+
|
30
|
+
repos_hash = {}
|
31
|
+
repo_id = choose do |menu|
|
32
|
+
menu.select_by = :index
|
33
|
+
menu.prompt = "Please select a repository:"
|
34
|
+
for repository in repositories
|
35
|
+
repos_hash[repository['name'].first] = repository
|
36
|
+
menu.choice(repository['name'].first)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
repository = repos_hash[repo_id]['permalink'].first
|
41
|
+
clone_url = repos_hash[repo_id]['clone-url'].first
|
42
|
+
|
43
|
+
export_path = File.join(project, repository)
|
44
|
+
folder = ask("Where would you like to clone this repository to? (default: #{export_path})")
|
45
|
+
unless folder.nil? || folder.empty?
|
46
|
+
export_path = folder
|
47
|
+
end
|
48
|
+
|
49
|
+
system("mkdir -p #{export_path}")
|
50
|
+
exec("git clone #{clone_url} #{export_path}")
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.5.0
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: xml-simple
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.12
|
34
|
+
version:
|
25
35
|
description:
|
26
36
|
email: adam@atechmedia.com
|
27
37
|
executables:
|
@@ -36,6 +46,7 @@ files:
|
|
36
46
|
- bin/codebase
|
37
47
|
- lib/codebase/command.rb
|
38
48
|
- lib/codebase/commands/branches.rb
|
49
|
+
- lib/codebase/commands/clone.rb
|
39
50
|
- lib/codebase/commands/deployments.rb
|
40
51
|
- lib/codebase/commands/launchers.rb
|
41
52
|
- lib/codebase/commands/setup.rb
|