git_cli 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/git_cli.gemspec +4 -4
- data/lib/git_cli/add_commit.rb +21 -3
- data/lib/git_cli/branch.rb +36 -17
- data/lib/git_cli/delta.rb +147 -40
- data/lib/git_cli/repos.rb +21 -10
- data/lib/git_cli/tags.rb +34 -16
- data/lib/git_cli/version.rb +1 -1
- data/lib/git_cli.rb +49 -6
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63fdc22895e48a0005e1fcaf0e5dc2291c6fdc26019ae566f1009424d083292c
|
4
|
+
data.tar.gz: 5e602e81ea3b378e185add93c6d8fb1ea97c48fc600c784c2e22aaa43beb0e21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a05ced2c8d7ec7b8efcc69ec6d1f41b80e11fbc5b3f1c1f5e7954800fd594d0d98aae0050ebab902d101ee7a7a653a2a989744f77bb7710aba367a10f3cf8719
|
7
|
+
data.tar.gz: e4a85fb3684d6b2377bf57ccd1e8e9c7c5b931997e22d1052c24de2a9c21d4792ff5c455e72e63d9e79fd9df863470b28bbb9e07dd8e6ea0e8ec5f29164f9901
|
data/git_cli.gemspec
CHANGED
@@ -27,10 +27,10 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_dependency "tlogger"
|
31
|
-
spec.add_dependency "toolrack"
|
32
|
-
spec.add_dependency "gvcs"
|
30
|
+
spec.add_dependency "tlogger"
|
31
|
+
spec.add_dependency "toolrack"
|
32
|
+
spec.add_dependency "gvcs"
|
33
33
|
spec.add_dependency "ptools", "~> 1.4.0"
|
34
34
|
|
35
|
-
spec.add_development_dependency 'devops_helper'
|
35
|
+
spec.add_development_dependency 'devops_helper' #, ">= 0.2.0"
|
36
36
|
end
|
data/lib/git_cli/add_commit.rb
CHANGED
@@ -18,6 +18,8 @@
|
|
18
18
|
module GitCli
|
19
19
|
module AddCommit
|
20
20
|
|
21
|
+
class CommitError < StandardError; end
|
22
|
+
|
21
23
|
def add_to_staging(paths)
|
22
24
|
check_vcs
|
23
25
|
|
@@ -37,7 +39,13 @@ module GitCli
|
|
37
39
|
log_debug "Add : #{cmdln}"
|
38
40
|
|
39
41
|
os_exec(cmdln) do |st, res|
|
40
|
-
|
42
|
+
res.strip!
|
43
|
+
if not st.success?
|
44
|
+
raise CommitError, res
|
45
|
+
else
|
46
|
+
res
|
47
|
+
end
|
48
|
+
#[st.success?, res.strip]
|
41
49
|
end
|
42
50
|
end # add_to_staging
|
43
51
|
alias :add :add_to_staging
|
@@ -118,7 +126,12 @@ module GitCli
|
|
118
126
|
log_debug "Commit : #{cmdln}"
|
119
127
|
|
120
128
|
os_exec(cmdln) do |st, res|
|
121
|
-
|
129
|
+
res.strip!
|
130
|
+
if not st.success?
|
131
|
+
raise CommitError, res
|
132
|
+
else
|
133
|
+
res
|
134
|
+
end
|
122
135
|
end
|
123
136
|
|
124
137
|
end # commit
|
@@ -143,7 +156,12 @@ module GitCli
|
|
143
156
|
log_debug "Commit All : #{cmdln}"
|
144
157
|
|
145
158
|
os_exec(cmdln) do |st, res|
|
146
|
-
|
159
|
+
res.strip!
|
160
|
+
if not st.success?
|
161
|
+
raise CommitError, res
|
162
|
+
else
|
163
|
+
res.strip
|
164
|
+
end
|
147
165
|
end
|
148
166
|
|
149
167
|
end # commit_all
|
data/lib/git_cli/branch.rb
CHANGED
@@ -18,6 +18,8 @@
|
|
18
18
|
|
19
19
|
module GitCli
|
20
20
|
module Branch
|
21
|
+
|
22
|
+
class BranchError < StandardError; end
|
21
23
|
|
22
24
|
def current_branch
|
23
25
|
|
@@ -50,9 +52,11 @@ module GitCli
|
|
50
52
|
# end
|
51
53
|
#end
|
52
54
|
|
53
|
-
|
55
|
+
res.strip
|
56
|
+
#[true, res.strip!]
|
54
57
|
else
|
55
|
-
|
58
|
+
raise BranchError, res.strip
|
59
|
+
#[false, res]
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
@@ -70,7 +74,8 @@ module GitCli
|
|
70
74
|
br.concat(rb)
|
71
75
|
end
|
72
76
|
|
73
|
-
|
77
|
+
br
|
78
|
+
#[true, br]
|
74
79
|
|
75
80
|
end # all_branches
|
76
81
|
|
@@ -95,9 +100,11 @@ module GitCli
|
|
95
100
|
res.each_line do |l|
|
96
101
|
b << l.strip
|
97
102
|
end
|
98
|
-
|
103
|
+
b
|
104
|
+
#[true, b]
|
99
105
|
else
|
100
|
-
|
106
|
+
raise BranchError, res.strip
|
107
|
+
#[false, res]
|
101
108
|
end
|
102
109
|
end
|
103
110
|
|
@@ -125,9 +132,11 @@ module GitCli
|
|
125
132
|
b << l.strip
|
126
133
|
end
|
127
134
|
|
128
|
-
[true, b]
|
135
|
+
#[true, b]
|
136
|
+
b
|
129
137
|
else
|
130
|
-
|
138
|
+
raise BranchError, res.strip
|
139
|
+
#[false, res]
|
131
140
|
end
|
132
141
|
end
|
133
142
|
|
@@ -151,9 +160,11 @@ module GitCli
|
|
151
160
|
log_debug "Switch branch : #{cmdln}"
|
152
161
|
res = os_exec(cmdln) do |st, res|
|
153
162
|
if st.success?
|
154
|
-
|
163
|
+
res.strip
|
164
|
+
#[true, res.strip]
|
155
165
|
else
|
156
|
-
|
166
|
+
raise BranchError, res.strip
|
167
|
+
#[false, res]
|
157
168
|
end
|
158
169
|
end
|
159
170
|
|
@@ -180,9 +191,11 @@ module GitCli
|
|
180
191
|
res = os_exec(cmdln) do |st, res|
|
181
192
|
|
182
193
|
if st.success?
|
183
|
-
|
194
|
+
res.strip
|
195
|
+
#[true, res.strip]
|
184
196
|
else
|
185
|
-
|
197
|
+
raise BranchError, res.strip
|
198
|
+
#[false, res]
|
186
199
|
end
|
187
200
|
end
|
188
201
|
|
@@ -205,9 +218,11 @@ module GitCli
|
|
205
218
|
res = os_exec(cmdln) do |st, res|
|
206
219
|
|
207
220
|
if st.success?
|
208
|
-
|
221
|
+
res.strip
|
222
|
+
#[true, res.strip]
|
209
223
|
else
|
210
|
-
|
224
|
+
raise BranchError, res.strip
|
225
|
+
#[false, res]
|
211
226
|
end
|
212
227
|
end
|
213
228
|
|
@@ -232,9 +247,11 @@ module GitCli
|
|
232
247
|
res = os_exec(cmdln) do |st, res|
|
233
248
|
|
234
249
|
if st.success?
|
235
|
-
|
250
|
+
res.strip
|
251
|
+
#[true, res.strip]
|
236
252
|
else
|
237
|
-
|
253
|
+
raise BranchError, res.strip
|
254
|
+
#[false, res]
|
238
255
|
end
|
239
256
|
end
|
240
257
|
|
@@ -260,9 +277,11 @@ module GitCli
|
|
260
277
|
res = os_exec(cmdln) do |st, res|
|
261
278
|
|
262
279
|
if st.success?
|
263
|
-
|
280
|
+
res.strip
|
281
|
+
#[true, res.strip]
|
264
282
|
else
|
265
|
-
|
283
|
+
raise BranchError, res.strip
|
284
|
+
#[false, res]
|
266
285
|
end
|
267
286
|
|
268
287
|
end
|
data/lib/git_cli/delta.rb
CHANGED
@@ -19,6 +19,102 @@
|
|
19
19
|
module GitCli
|
20
20
|
module Delta
|
21
21
|
|
22
|
+
class GitDeltaError < StandardError; end
|
23
|
+
class VCSItem
|
24
|
+
attr_reader :path, :full, :type
|
25
|
+
def initialize(type, path, full)
|
26
|
+
@type = type
|
27
|
+
@path = path
|
28
|
+
@full = full
|
29
|
+
end
|
30
|
+
|
31
|
+
# support sort
|
32
|
+
def <=>(val)
|
33
|
+
@path <=> val.path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
class NewDir < VCSItem
|
37
|
+
def initialize(path, full)
|
38
|
+
super(:dir, path, full)
|
39
|
+
end
|
40
|
+
def to_s
|
41
|
+
"[N] #{@path}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
class NewFile < VCSItem
|
45
|
+
def initialize(path, full)
|
46
|
+
super(:file, path, full)
|
47
|
+
end
|
48
|
+
def to_s
|
49
|
+
"[N] #{@path}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
class ModifiedDir < VCSItem
|
53
|
+
def initialize(path, full)
|
54
|
+
super(:dir, path, full)
|
55
|
+
end
|
56
|
+
def to_s
|
57
|
+
"[M] #{@path}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
class ModifiedFile < VCSItem
|
61
|
+
def initialize(path, full)
|
62
|
+
super(:file, path, full)
|
63
|
+
end
|
64
|
+
def to_s
|
65
|
+
"[M] #{@path}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
class DeletedDir < VCSItem
|
69
|
+
def initialize(path, full)
|
70
|
+
super(:dir, path, full)
|
71
|
+
end
|
72
|
+
def to_s
|
73
|
+
"[D] #{@path}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
class DeletedFile < VCSItem
|
77
|
+
def initialize(path, full)
|
78
|
+
super(:file, path, full)
|
79
|
+
end
|
80
|
+
def to_s
|
81
|
+
"[D] #{@path}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
class StagedDir < VCSItem
|
85
|
+
def initialize(path, full)
|
86
|
+
super(:dir, path, full)
|
87
|
+
end
|
88
|
+
def to_s
|
89
|
+
"[S] #{@path}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
class StagedFile < VCSItem
|
93
|
+
def initialize(path, full)
|
94
|
+
super(:file, path, full)
|
95
|
+
end
|
96
|
+
def to_s
|
97
|
+
"[S] #{@path}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
class ConflictedDir < VCSItem
|
101
|
+
def initialize(path, full)
|
102
|
+
super(:dir, path, full)
|
103
|
+
end
|
104
|
+
def to_s
|
105
|
+
"[C] #{@path}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
class ConflictedFile < VCSItem
|
109
|
+
def initialize(path, full)
|
110
|
+
super(:file, path, full)
|
111
|
+
end
|
112
|
+
def to_s
|
113
|
+
"[C] #{@path}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
22
118
|
def status
|
23
119
|
|
24
120
|
check_vcs
|
@@ -34,11 +130,16 @@ module GitCli
|
|
34
130
|
log_debug "Status : #{cmdln}"
|
35
131
|
res = os_exec(cmdln) do |st, res|
|
36
132
|
|
37
|
-
if st.success?
|
38
|
-
|
133
|
+
if not st.success?
|
134
|
+
raise GitDeltaError, res
|
39
135
|
else
|
40
|
-
|
136
|
+
res
|
41
137
|
end
|
138
|
+
#if st.success?
|
139
|
+
# [true, res]
|
140
|
+
#else
|
141
|
+
# [false, res]
|
142
|
+
#end
|
42
143
|
end
|
43
144
|
|
44
145
|
end # status
|
@@ -61,19 +162,21 @@ module GitCli
|
|
61
162
|
files = []
|
62
163
|
res = os_exec(cmdln) do |st, res|
|
63
164
|
|
64
|
-
if st.success?
|
165
|
+
if not st.success?
|
166
|
+
raise GitDeltaError, res
|
167
|
+
else
|
65
168
|
res.each_line do |l|
|
66
169
|
l.chomp!
|
67
|
-
|
68
|
-
|
170
|
+
full = File.join(@wsPath,l)
|
171
|
+
if File.directory?(full)
|
172
|
+
dirs << ModifiedDir.new(l,full)
|
69
173
|
else
|
70
|
-
files << l
|
174
|
+
files << ModifiedFile.new(l,full)
|
71
175
|
end
|
72
176
|
end
|
73
177
|
|
74
|
-
[true, dirs.sort, files.sort]
|
75
|
-
|
76
|
-
[false, [], []]
|
178
|
+
#[true, dirs.sort, files.sort]
|
179
|
+
[dirs.sort, files.sort]
|
77
180
|
end
|
78
181
|
|
79
182
|
end
|
@@ -96,19 +199,20 @@ module GitCli
|
|
96
199
|
files = []
|
97
200
|
res = os_exec(cmdln) do |st, res|
|
98
201
|
|
99
|
-
if st.success?
|
202
|
+
if not st.success?
|
203
|
+
raise GitDeltaError, res
|
204
|
+
else
|
100
205
|
res.each_line do |l|
|
101
206
|
l.chomp!
|
102
|
-
|
103
|
-
|
207
|
+
full = File.join(@wsPath,l)
|
208
|
+
if File.directory?(full)
|
209
|
+
dirs << ConflictedDir.new(l, full)
|
104
210
|
else
|
105
|
-
files << l
|
211
|
+
files << ConflictedFile.new(l, full)
|
106
212
|
end
|
107
213
|
end
|
108
214
|
|
109
|
-
[
|
110
|
-
else
|
111
|
-
[false, [], []]
|
215
|
+
[dirs.sort, files.sort]
|
112
216
|
end
|
113
217
|
|
114
218
|
end
|
@@ -131,19 +235,20 @@ module GitCli
|
|
131
235
|
files = []
|
132
236
|
res = os_exec(cmdln) do |st, res|
|
133
237
|
|
134
|
-
if st.success?
|
238
|
+
if not st.success?
|
239
|
+
raise GitDeltaError, res
|
240
|
+
else
|
135
241
|
res.each_line do |l|
|
136
242
|
l.chomp!
|
137
|
-
|
138
|
-
|
243
|
+
full = File.join(@wsPath,l)
|
244
|
+
if File.directory?(full)
|
245
|
+
dirs << NewDir.new(l,full)
|
139
246
|
else
|
140
|
-
files << l
|
247
|
+
files << NewFile.new(l,full)
|
141
248
|
end
|
142
249
|
end
|
143
250
|
|
144
|
-
[
|
145
|
-
else
|
146
|
-
[false, [], []]
|
251
|
+
[dirs.sort, files.sort]
|
147
252
|
end
|
148
253
|
end
|
149
254
|
|
@@ -166,19 +271,20 @@ module GitCli
|
|
166
271
|
files = []
|
167
272
|
res = os_exec(cmdln) do |st, res|
|
168
273
|
|
169
|
-
if st.success?
|
274
|
+
if not st.success?
|
275
|
+
raise GitDeltaError, res
|
276
|
+
else
|
170
277
|
res.each_line do |l|
|
171
278
|
l.chomp!
|
172
|
-
|
173
|
-
|
279
|
+
full = File.join(@wsPath,l)
|
280
|
+
if File.directory?(full)
|
281
|
+
dirs << DeletedDir.new(l,full)
|
174
282
|
else
|
175
|
-
files << l
|
283
|
+
files << DeletedFile.new(l,full)
|
176
284
|
end
|
177
285
|
end
|
178
286
|
|
179
|
-
[
|
180
|
-
else
|
181
|
-
[false, [], []]
|
287
|
+
[dirs.sort, files.sort]
|
182
288
|
end
|
183
289
|
end
|
184
290
|
|
@@ -196,24 +302,25 @@ module GitCli
|
|
196
302
|
cmd << "diff --name-only --cached"
|
197
303
|
|
198
304
|
cmdln = cmd.join(" ")
|
199
|
-
log_debug "
|
305
|
+
log_debug "Staged Files : #{cmdln}"
|
200
306
|
dirs = []
|
201
307
|
files = []
|
202
308
|
res = os_exec(cmdln) do |st, res|
|
203
309
|
|
204
|
-
if st.success?
|
310
|
+
if not st.success?
|
311
|
+
raise GitDeltaError, res
|
312
|
+
else
|
205
313
|
res.each_line do |l|
|
206
314
|
l.chomp!
|
207
|
-
|
208
|
-
|
315
|
+
full = File.join(@wsPath,l)
|
316
|
+
if File.directory?(full)
|
317
|
+
dirs << StagedDir.new(l,full)
|
209
318
|
else
|
210
|
-
files << l
|
319
|
+
files << StagedFile.new(l,full)
|
211
320
|
end
|
212
321
|
end
|
213
322
|
|
214
|
-
[
|
215
|
-
else
|
216
|
-
[false, [], []]
|
323
|
+
[dirs.sort, files.sort]
|
217
324
|
end
|
218
325
|
end
|
219
326
|
|
@@ -221,7 +328,7 @@ module GitCli
|
|
221
328
|
|
222
329
|
def reset_file_changes(path)
|
223
330
|
|
224
|
-
raise_if_empty(path, "Path cannot be empty for reset file changes operation",
|
331
|
+
raise_if_empty(path, "Path cannot be empty for reset file changes operation", GitDeltaError)
|
225
332
|
|
226
333
|
check_vcs
|
227
334
|
|
data/lib/git_cli/repos.rb
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
|
19
19
|
module GitCli
|
20
20
|
module Repos
|
21
|
+
class ReposError < StandardError; end
|
21
22
|
|
22
23
|
def remote_config
|
23
24
|
check_vcs
|
@@ -32,21 +33,26 @@ module GitCli
|
|
32
33
|
cmdln = cmd.join(" ")
|
33
34
|
log_debug "Remote config : #{cmdln}"
|
34
35
|
res = os_exec(cmdln) do |st, res|
|
35
|
-
|
36
|
+
|
36
37
|
if st.success?
|
37
38
|
|
38
39
|
remotes = { }
|
39
40
|
res.each_line do |l|
|
40
41
|
ls = l.split("\t")
|
41
42
|
lss = ls[1].split(" ")
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
|
44
|
+
remotes[ls[0]] = { } if is_empty?(remotes[ls[0]])
|
45
|
+
rem = remotes[ls[0]]
|
46
|
+
type = lss[-1]
|
47
|
+
type.gsub!("(","").gsub!(")","")
|
48
|
+
rem[type] = lss[0]
|
45
49
|
end
|
46
50
|
|
47
|
-
[true, remotes]
|
51
|
+
#[true, remotes]
|
52
|
+
remotes
|
48
53
|
else
|
49
|
-
|
54
|
+
raise ReposError, res.strip
|
55
|
+
#[false, res]
|
50
56
|
end
|
51
57
|
end
|
52
58
|
|
@@ -74,9 +80,11 @@ module GitCli
|
|
74
80
|
res = os_exec(cmdln) do |st, res|
|
75
81
|
|
76
82
|
if st.success?
|
77
|
-
[true, res.strip]
|
83
|
+
#[true, res.strip]
|
84
|
+
res.strip
|
78
85
|
else
|
79
|
-
|
86
|
+
raise ReposError, res.strip
|
87
|
+
#[false, res.strip]
|
80
88
|
end
|
81
89
|
end
|
82
90
|
|
@@ -103,13 +111,16 @@ module GitCli
|
|
103
111
|
res = os_exec(cmdln) do |st, res|
|
104
112
|
|
105
113
|
if st.success?
|
106
|
-
[true, res.strip]
|
114
|
+
#[true, res.strip]
|
115
|
+
res.strip
|
107
116
|
else
|
108
|
-
|
117
|
+
raise ReposError, res.strip
|
118
|
+
#[false, res.strip]
|
109
119
|
end
|
110
120
|
end
|
111
121
|
|
112
122
|
end # remove_remote
|
123
|
+
alias_method :remove_del, :remove_remote
|
113
124
|
|
114
125
|
|
115
126
|
|
data/lib/git_cli/tags.rb
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
module GitCli
|
20
20
|
module Tags
|
21
21
|
|
22
|
+
class TagError < StandardError; end
|
23
|
+
|
22
24
|
def all_tags
|
23
25
|
|
24
26
|
check_vcs
|
@@ -35,9 +37,11 @@ module GitCli
|
|
35
37
|
res = os_exec(cmdln) do |st, res|
|
36
38
|
|
37
39
|
if st.success?
|
38
|
-
|
40
|
+
res.strip
|
41
|
+
#[true, res.strip!]
|
39
42
|
else
|
40
|
-
|
43
|
+
raise TagError, res
|
44
|
+
#[false, res]
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
@@ -144,9 +148,11 @@ module GitCli
|
|
144
148
|
log_debug "New tag : #{cmdln}"
|
145
149
|
res = os_exec(cmdln) do |st, res|
|
146
150
|
if st.success?
|
147
|
-
[true, res.strip!]
|
151
|
+
#[true, res.strip!]
|
152
|
+
res.strip
|
148
153
|
else
|
149
|
-
|
154
|
+
raise TagError, res
|
155
|
+
#[false, res]
|
150
156
|
end
|
151
157
|
end
|
152
158
|
|
@@ -186,9 +192,11 @@ module GitCli
|
|
186
192
|
log_debug "New tag from commit ID : #{cmdln}"
|
187
193
|
res = os_exec(cmdln) do |st, res|
|
188
194
|
if st.success?
|
189
|
-
|
195
|
+
res.strip
|
196
|
+
#[true, res.strip!]
|
190
197
|
else
|
191
|
-
|
198
|
+
raise TagError, res
|
199
|
+
#[false, res]
|
192
200
|
end
|
193
201
|
end
|
194
202
|
|
@@ -211,9 +219,11 @@ module GitCli
|
|
211
219
|
res = os_exec(cmdln) do |st, res|
|
212
220
|
|
213
221
|
if st.success?
|
214
|
-
[true, res.strip!]
|
222
|
+
#[true, res.strip!]
|
223
|
+
res.strip
|
215
224
|
else
|
216
|
-
|
225
|
+
raise TagError, res
|
226
|
+
#[false, res]
|
217
227
|
end
|
218
228
|
end
|
219
229
|
|
@@ -241,9 +251,11 @@ module GitCli
|
|
241
251
|
log_debug "Show tag '#{tag}' #{not_empty?(format) ? "[#{format}]" : ""} : #{cmdln}"
|
242
252
|
res = os_exec(cmdln) do |st, res|
|
243
253
|
if st.success?
|
244
|
-
|
254
|
+
res.strip
|
255
|
+
#[true, res.strip!]
|
245
256
|
else
|
246
|
-
|
257
|
+
raise TagError, res
|
258
|
+
#[false, res]
|
247
259
|
end
|
248
260
|
end
|
249
261
|
|
@@ -266,9 +278,11 @@ module GitCli
|
|
266
278
|
log_debug "Delete tag '#{tag}' : #{cmdln}"
|
267
279
|
res = os_exec(cmdln) do |st, res|
|
268
280
|
if st.success?
|
269
|
-
|
281
|
+
res.strip
|
282
|
+
#[true, res.strip!]
|
270
283
|
else
|
271
|
-
|
284
|
+
raise TagError, res
|
285
|
+
#[false, res]
|
272
286
|
end
|
273
287
|
end
|
274
288
|
|
@@ -293,9 +307,11 @@ module GitCli
|
|
293
307
|
log_debug "Delete remote tag '#{tag}' at '#{repos}': #{cmdln}"
|
294
308
|
res = os_exec(cmdln) do |st, res|
|
295
309
|
if st.success?
|
296
|
-
|
310
|
+
res
|
311
|
+
#[true, res.strip!]
|
297
312
|
else
|
298
|
-
|
313
|
+
raise TagError, res
|
314
|
+
#[false, res]
|
299
315
|
end
|
300
316
|
end
|
301
317
|
|
@@ -321,9 +337,11 @@ module GitCli
|
|
321
337
|
log_debug "Checkout tag '#{tag}' into branch '#{branch}': #{cmdln}"
|
322
338
|
res = os_exec(cmdln) do |st, res|
|
323
339
|
if st.success?
|
324
|
-
|
340
|
+
res.strip
|
341
|
+
#[true, res.strip!]
|
325
342
|
else
|
326
|
-
|
343
|
+
raise TagError, res
|
344
|
+
#[false, res]
|
327
345
|
end
|
328
346
|
end
|
329
347
|
|
data/lib/git_cli/version.rb
CHANGED
data/lib/git_cli.rb
CHANGED
@@ -118,13 +118,21 @@ module GitCli
|
|
118
118
|
include GitCli::Repos
|
119
119
|
include GitCli::Stash
|
120
120
|
|
121
|
+
include TR::CondUtils
|
122
|
+
|
121
123
|
attr_accessor :repos
|
122
|
-
def initialize(
|
124
|
+
def initialize(path, vcs = nil)
|
123
125
|
|
124
|
-
raise_if_empty(vcs , "VCS cannot be empty", GitCliException)
|
126
|
+
#raise_if_empty(vcs , "VCS cannot be empty", GitCliException)
|
125
127
|
raise_if_empty(path, "Workspace path cannot be empty", GitCliException)
|
126
|
-
|
127
|
-
|
128
|
+
|
129
|
+
if is_empty?(vcs)
|
130
|
+
@vcs = Gvcs::Vcs.new
|
131
|
+
else
|
132
|
+
@vcs = vcs
|
133
|
+
end
|
134
|
+
|
135
|
+
#@vcs = vcs
|
128
136
|
@givenPath = path
|
129
137
|
|
130
138
|
@wsPath = File.expand_path(@givenPath)
|
@@ -151,6 +159,7 @@ module GitCli
|
|
151
159
|
|
152
160
|
def is_repos_exist?(name)
|
153
161
|
found = false
|
162
|
+
load_remote_to_repos
|
154
163
|
@repos.each do |re|
|
155
164
|
if re.name == name
|
156
165
|
found = true
|
@@ -161,8 +170,15 @@ module GitCli
|
|
161
170
|
end # is_repos_exist?
|
162
171
|
|
163
172
|
def is_workspace?
|
164
|
-
|
165
|
-
|
173
|
+
begin
|
174
|
+
status
|
175
|
+
true
|
176
|
+
rescue GitDeltaError => ex
|
177
|
+
log_debug ex.message
|
178
|
+
false
|
179
|
+
end
|
180
|
+
#st, res = status
|
181
|
+
#st
|
166
182
|
end
|
167
183
|
|
168
184
|
def workspace_root
|
@@ -195,6 +211,16 @@ module GitCli
|
|
195
211
|
|
196
212
|
end # workspace_root
|
197
213
|
|
214
|
+
def load_remote_to_repos
|
215
|
+
conf = remote_config
|
216
|
+
conf.each do |k,v|
|
217
|
+
repo = Gvcs::Repository.new(k, v.values.first)
|
218
|
+
repo.support_fetch if v.keys.include?("fetch")
|
219
|
+
repo.support_push if v.keys.include?("push")
|
220
|
+
add_repos(repo)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
198
224
|
end # Gvcs::Workspace
|
199
225
|
|
200
226
|
|
@@ -208,12 +234,29 @@ module GitCli
|
|
208
234
|
@url = url
|
209
235
|
#@branches = branches
|
210
236
|
@sslVerify = true
|
237
|
+
|
238
|
+
@fetch = false
|
239
|
+
@push = false
|
211
240
|
end
|
212
241
|
|
213
242
|
def ssl_verify(bool)
|
214
243
|
@sslVerify = bool
|
215
244
|
end
|
216
245
|
|
246
|
+
def support_fetch
|
247
|
+
@fetch = true
|
248
|
+
end
|
249
|
+
def is_fetch_supported?
|
250
|
+
@fetch
|
251
|
+
end
|
252
|
+
|
253
|
+
def support_push
|
254
|
+
@push = true
|
255
|
+
end
|
256
|
+
def is_push_supported?
|
257
|
+
@push
|
258
|
+
end
|
259
|
+
|
217
260
|
end # repository
|
218
261
|
|
219
262
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Liaw
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tlogger
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: toolrack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gvcs
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: ptools
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0
|
82
|
+
version: '0'
|
83
83
|
description: Interface to GIT via command line interface instead of some sor of library
|
84
84
|
email:
|
85
85
|
- chrisliaw@antrapol.com
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.2.22
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: GIT command line interface
|