git_cli 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.release_history.yml +2 -0
- data/Gemfile.lock +4 -29
- data/git_cli.gemspec +2 -1
- data/lib/git_cli/add_commit.rb +9 -8
- data/lib/git_cli/delta.rb +18 -2
- data/lib/git_cli/diff.rb +6 -6
- data/lib/git_cli/ignore.rb +6 -4
- data/lib/git_cli/tags.rb +27 -0
- data/lib/git_cli/version.rb +1 -1
- data/lib/git_cli.rb +21 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc750608285dcc1362ed54813744bc70765f74a808dc3a6f833fa2b846cdf93e
|
4
|
+
data.tar.gz: 9a686f33dc16a654fc534999098ef7e8981c8ebf5264429ffd837e62cfabd175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1912f145438b920f90efc5cf42b78fe2d2bb163d240ffd5a67124d541529bb7e02e740bf9d5c1ab85e5a94230532739cd5cbe3a05637fd7b9b07a8e5f4a41cb3
|
7
|
+
data.tar.gz: '060151482263dc869181d9ad369cd8e5b1aec32b126dd67e03a5365d59e45834751a21065ae9e725c2e1b8a977cddc75094d4b1917aa8cf1117c424d4b1e859d'
|
data/.gitignore
CHANGED
data/.release_history.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
git_cli (0.11.
|
4
|
+
git_cli (0.11.2)
|
5
5
|
gvcs
|
6
6
|
ptools (~> 1.4.0)
|
7
7
|
teLogger
|
@@ -10,44 +10,19 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
|
14
|
-
devops_assist (0.3.1)
|
15
|
-
git_cli
|
16
|
-
git_cli_prompt
|
17
|
-
gvcs
|
18
|
-
teLogger
|
19
|
-
toolrack
|
20
|
-
tty-prompt
|
21
|
-
git_cli_prompt (0.3.1)
|
22
|
-
teLogger
|
23
|
-
toolrack
|
24
|
-
tty-prompt
|
13
|
+
gem-release (2.2.2)
|
25
14
|
gvcs (0.1.1)
|
26
15
|
minitest (5.17.0)
|
27
|
-
pastel (0.8.0)
|
28
|
-
tty-color (~> 0.5)
|
29
16
|
ptools (1.4.3)
|
30
17
|
rake (12.3.3)
|
31
18
|
teLogger (0.2.2)
|
32
|
-
toolrack (0.
|
33
|
-
base58
|
34
|
-
tty-color (0.6.0)
|
35
|
-
tty-cursor (0.7.1)
|
36
|
-
tty-prompt (0.23.1)
|
37
|
-
pastel (~> 0.8)
|
38
|
-
tty-reader (~> 0.8)
|
39
|
-
tty-reader (0.9.0)
|
40
|
-
tty-cursor (~> 0.7)
|
41
|
-
tty-screen (~> 0.8)
|
42
|
-
wisper (~> 2.0)
|
43
|
-
tty-screen (0.8.1)
|
44
|
-
wisper (2.0.1)
|
19
|
+
toolrack (0.21.0)
|
45
20
|
|
46
21
|
PLATFORMS
|
47
22
|
x86_64-linux
|
48
23
|
|
49
24
|
DEPENDENCIES
|
50
|
-
|
25
|
+
gem-release
|
51
26
|
git_cli!
|
52
27
|
minitest (~> 5.0)
|
53
28
|
rake (~> 12.0)
|
data/git_cli.gemspec
CHANGED
@@ -34,5 +34,6 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "ptools", "~> 1.4.0"
|
35
35
|
|
36
36
|
#spec.add_development_dependency 'devops_helper' #, ">= 0.2.0"
|
37
|
-
spec.add_development_dependency 'devops_assist' #, ">= 0.2.0"
|
37
|
+
#spec.add_development_dependency 'devops_assist' #, ">= 0.2.0"
|
38
|
+
spec.add_development_dependency 'gem-release'
|
38
39
|
end
|
data/lib/git_cli/add_commit.rb
CHANGED
@@ -20,7 +20,7 @@ module GitCli
|
|
20
20
|
|
21
21
|
class CommitError < StandardError; end
|
22
22
|
|
23
|
-
def add_to_staging(paths)
|
23
|
+
def add_to_staging(*paths)
|
24
24
|
check_vcs
|
25
25
|
|
26
26
|
raise_if_empty(paths, "Given path to add is empty", GitCliException)
|
@@ -33,7 +33,7 @@ module GitCli
|
|
33
33
|
cmd << "&&"
|
34
34
|
cmd << @vcs.exe_path
|
35
35
|
cmd << "add"
|
36
|
-
cmd.append(paths)
|
36
|
+
cmd.append(paths.join(" "))
|
37
37
|
cmdln = cmd.join " "
|
38
38
|
|
39
39
|
log_debug "Add : #{cmdln}"
|
@@ -126,12 +126,13 @@ module GitCli
|
|
126
126
|
log_debug "Commit : #{cmdln}"
|
127
127
|
|
128
128
|
os_exec(cmdln) do |st, res|
|
129
|
-
res.strip!
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
129
|
+
[st.success?, res.strip!]
|
130
|
+
#res.strip!
|
131
|
+
#if not st.success?
|
132
|
+
# raise CommitError, res
|
133
|
+
#else
|
134
|
+
# res
|
135
|
+
#end
|
135
136
|
end
|
136
137
|
|
137
138
|
end # commit
|
data/lib/git_cli/delta.rb
CHANGED
@@ -32,6 +32,10 @@ module GitCli
|
|
32
32
|
def <=>(val)
|
33
33
|
@path <=> val.path
|
34
34
|
end
|
35
|
+
|
36
|
+
def ==(val)
|
37
|
+
@path == val.path
|
38
|
+
end
|
35
39
|
end
|
36
40
|
class NewDir < VCSItem
|
37
41
|
def initialize(path, full)
|
@@ -394,13 +398,25 @@ module GitCli
|
|
394
398
|
|
395
399
|
def is_local_ahead_of_remote?(remote_name, branch = "main")
|
396
400
|
|
397
|
-
calculate_distance("#{remote_name}/#{branch}", "HEAD")
|
401
|
+
st, res = calculate_distance("#{remote_name}/#{branch}", "HEAD")
|
402
|
+
if st
|
403
|
+
res.to_i > 0
|
404
|
+
else
|
405
|
+
# not push before
|
406
|
+
true
|
407
|
+
end
|
398
408
|
|
399
409
|
end
|
400
410
|
|
401
411
|
def is_remote_ahead_of_local?(remote_name, branch = "main")
|
402
412
|
|
403
|
-
calculate_distance("HEAD","#{remote_name}/#{branch}")
|
413
|
+
st, res = calculate_distance("HEAD","#{remote_name}/#{branch}")
|
414
|
+
if st
|
415
|
+
res.to_i > 0
|
416
|
+
else
|
417
|
+
# never pull before?
|
418
|
+
true
|
419
|
+
end
|
404
420
|
end
|
405
421
|
|
406
422
|
end
|
data/lib/git_cli/diff.rb
CHANGED
@@ -74,12 +74,12 @@ module GitCli
|
|
74
74
|
log_debug "#{opts[:log_tag]} : #{cmdln} "
|
75
75
|
|
76
76
|
res = os_exec(cmdln) do |st, res|
|
77
|
-
|
78
|
-
if st.success?
|
79
|
-
|
80
|
-
else
|
81
|
-
|
82
|
-
end
|
77
|
+
[st.success?, res.strip!]
|
78
|
+
#if st.success?
|
79
|
+
# [true, res.strip!]
|
80
|
+
#else
|
81
|
+
# [false, res]
|
82
|
+
#end
|
83
83
|
end
|
84
84
|
|
85
85
|
end
|
data/lib/git_cli/ignore.rb
CHANGED
@@ -20,9 +20,10 @@ module GitCli
|
|
20
20
|
module Ignore
|
21
21
|
|
22
22
|
def ignore(*val)
|
23
|
-
with_ignore_file do |f|
|
23
|
+
with_ignore_file("a+") do |f|
|
24
|
+
cont = f.read
|
24
25
|
val.each do |v|
|
25
|
-
f.puts v
|
26
|
+
f.puts(v) if (cont =~ /^#{v}\Z/) == nil
|
26
27
|
end
|
27
28
|
#f.puts val
|
28
29
|
end
|
@@ -62,14 +63,15 @@ module GitCli
|
|
62
63
|
end
|
63
64
|
|
64
65
|
private
|
65
|
-
def with_ignore_file(&block)
|
66
|
+
def with_ignore_file(mode = "a", &block)
|
67
|
+
mode = "a" if is_empty?(mode)
|
66
68
|
if block
|
67
69
|
st, root = workspace_root
|
68
70
|
root.strip!
|
69
71
|
if st
|
70
72
|
igPath = File.join(root,".gitignore")
|
71
73
|
FileUtils.touch(igPath) if not File.exist?(igPath)
|
72
|
-
File.open(igPath,
|
74
|
+
File.open(igPath,mode) do |f|
|
73
75
|
block.call(f)
|
74
76
|
end
|
75
77
|
else
|
data/lib/git_cli/tags.rb
CHANGED
@@ -347,5 +347,32 @@ module GitCli
|
|
347
347
|
|
348
348
|
end # checkout_tag
|
349
349
|
|
350
|
+
def tag_points_at?(dest = "HEAD")
|
351
|
+
|
352
|
+
#raise_if_empty(tag, "Tag name cannot be empty", GitCliException)
|
353
|
+
|
354
|
+
check_vcs
|
355
|
+
|
356
|
+
cmd = []
|
357
|
+
cmd << "cd"
|
358
|
+
cmd << @wsPath
|
359
|
+
cmd << "&&"
|
360
|
+
cmd << @vcs.exe_path
|
361
|
+
cmd << "tag"
|
362
|
+
cmd << "--points-at"
|
363
|
+
cmd << dest
|
364
|
+
|
365
|
+
cmdln = cmd.join(" ")
|
366
|
+
log_debug "Check if current tag is pointing to #{dest}"
|
367
|
+
res = os_exec(cmdln) do |st, res|
|
368
|
+
if st.success?
|
369
|
+
not_empty?(res.strip)
|
370
|
+
else
|
371
|
+
raise TagError, res
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
end # is_tag_points_at?
|
376
|
+
|
350
377
|
end
|
351
378
|
end
|
data/lib/git_cli/version.rb
CHANGED
data/lib/git_cli.rb
CHANGED
@@ -51,14 +51,18 @@ module GitCli
|
|
51
51
|
|
52
52
|
# redirect stderr to stdout
|
53
53
|
path = "#{path} 2>&1"
|
54
|
-
|
55
|
-
|
56
|
-
# $?.exitstatus => error codes
|
57
|
-
# $?.success? => true / false
|
58
|
-
# $?.pid => child PID
|
59
|
-
block.call($?, res)
|
54
|
+
if dry_run
|
55
|
+
block.call(:dry_run_command, path) if block
|
60
56
|
else
|
61
|
-
res.
|
57
|
+
res = Antrapol::ToolRack::ProcessUtilsEngine.exec(path)
|
58
|
+
if block
|
59
|
+
# $?.exitstatus => error codes
|
60
|
+
# $?.success? => true / false
|
61
|
+
# $?.pid => child PID
|
62
|
+
block.call($?, res)
|
63
|
+
else
|
64
|
+
res.strip
|
65
|
+
end
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
@@ -73,6 +77,14 @@ module GitCli
|
|
73
77
|
def log_warn(str)
|
74
78
|
GitCli::Global.instance.logger.warn(str)
|
75
79
|
end
|
80
|
+
|
81
|
+
def dry_run=(val)
|
82
|
+
@dry_run = val if not_empty?(val) and is_bool?(val)
|
83
|
+
end
|
84
|
+
|
85
|
+
def dry_run
|
86
|
+
@dry_run.nil? ? false : @dry_run
|
87
|
+
end
|
76
88
|
end # common operations
|
77
89
|
|
78
90
|
class Gvcs::Vcs
|
@@ -202,9 +214,9 @@ module GitCli
|
|
202
214
|
res = os_exec(cmdln) do |st, res|
|
203
215
|
|
204
216
|
if st.success?
|
205
|
-
@wsRoot = [true, res]
|
217
|
+
@wsRoot = [true, res.strip]
|
206
218
|
else
|
207
|
-
@wsRoot = [false, res]
|
219
|
+
@wsRoot = [false, res.strip]
|
208
220
|
end
|
209
221
|
end
|
210
222
|
|
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.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Liaw
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: teLogger
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.4.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: gem-release
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.4.10
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: GIT command line interface
|