git_local 0.0.8 → 0.0.9
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/Gemfile.lock +2 -2
- data/lib/git_local/repository.rb +19 -2
- data/lib/git_local/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22266f5287de8aa48c572c13ba861a27f202b1f4
|
4
|
+
data.tar.gz: 2daf4f2fda66c794d3cd5215232ce858f3f6f46d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf3065a45ad15f27c83c473cb905b2147cd1895cb98f21a8a948dfc1a563cdde8737e5dcb3ee1c7cb38c80f28524c1c22693ebbea937fb42522ae4a5daa58074
|
7
|
+
data.tar.gz: bec1798210fe76a38154c4c0c5322ece1ac180f108c49e04b2523457300b670ae9f1d84060235806655e7e46b24196ea845c995cbbd4d8702dc16ba033f5fdb5
|
data/Gemfile.lock
CHANGED
data/lib/git_local/repository.rb
CHANGED
@@ -6,15 +6,24 @@ module GitLocal
|
|
6
6
|
class InvalidArgument < StandardError
|
7
7
|
end
|
8
8
|
|
9
|
+
class InvalidProtocol < StandardError
|
10
|
+
end
|
11
|
+
|
9
12
|
GITHUB_HOST = "github.com".freeze
|
13
|
+
VALID_PROTOCOLS = {
|
14
|
+
ssh: "SSH",
|
15
|
+
https: "HTTPS"
|
16
|
+
}.freeze
|
10
17
|
|
11
|
-
def initialize(org:, repo:, branch:, local_directory:, host: GITHUB_HOST)
|
18
|
+
def initialize(org:, repo:, branch:, local_directory:, host: GITHUB_HOST, protocol: VALID_PROTOCOLS[:ssh])
|
12
19
|
check_for_special_characters(org, repo, branch, local_directory)
|
13
20
|
@branch = branch
|
14
21
|
@host = host
|
15
22
|
@local_directory = local_directory
|
16
23
|
@org = org
|
17
24
|
@repo = repo
|
25
|
+
@protocol = protocol
|
26
|
+
validate_protocol
|
18
27
|
end
|
19
28
|
|
20
29
|
def get
|
@@ -82,7 +91,7 @@ module GitLocal
|
|
82
91
|
def clone_and_checkout
|
83
92
|
FileUtils.makedirs(repo_path) unless Dir.exist?(repo_path)
|
84
93
|
|
85
|
-
popened_io = IO.popen("(cd #{repo_path} && git clone
|
94
|
+
popened_io = IO.popen("(cd #{repo_path} && git clone #{repo_endpoint} --branch #{branch} --single-branch #{branch} && cd #{path}) 2>&1")
|
86
95
|
out = popened_io.map(&:chomp) || []
|
87
96
|
Process.wait(popened_io.pid)
|
88
97
|
|
@@ -104,5 +113,13 @@ module GitLocal
|
|
104
113
|
def repo_path
|
105
114
|
@repo_path ||= "#{local_directory}/#{org_repo}"
|
106
115
|
end
|
116
|
+
|
117
|
+
def validate_protocol
|
118
|
+
raise InvalidProtocol, "Protocol must be either HTTPS or SSH." unless VALID_PROTOCOLS.values.include?(@protocol)
|
119
|
+
end
|
120
|
+
|
121
|
+
def repo_endpoint
|
122
|
+
@protocol == VALID_PROTOCOLS[:ssh] ? "git@#{host}:#{org_repo}.git" : "https://#{host}/#{org_repo}.git"
|
123
|
+
end
|
107
124
|
end
|
108
125
|
end
|
data/lib/git_local/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_local
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Galvanize Product
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|