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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0aee5685cf56c36288182240355094917487d664010a6caa90e3d78421450d4
4
- data.tar.gz: 33f3358634f113136a64c5452a07df9ecb19c81970d19aa6c773e5ce6e4990f0
3
+ metadata.gz: bc750608285dcc1362ed54813744bc70765f74a808dc3a6f833fa2b846cdf93e
4
+ data.tar.gz: 9a686f33dc16a654fc534999098ef7e8981c8ebf5264429ffd837e62cfabd175
5
5
  SHA512:
6
- metadata.gz: 7ff51d738b56ce0ff39e7b1477b66a3d517724f4a6a9a6c9c0ba1f552d205c7f39e3955f1e1ddee666ad3cb75657b4ebe8a0f104986c280c4c44913235b4973c
7
- data.tar.gz: a27a52eb0b278877a8118f6233d053ddb0d7dcbb3c9c798e8009a61ce336d9647f06fba955b38a7c484c6430085ed93e5cd9a843781bfa38e0e01dfc7c8dbe9d
6
+ metadata.gz: 1912f145438b920f90efc5cf42b78fe2d2bb163d240ffd5a67124d541529bb7e02e740bf9d5c1ab85e5a94230532739cd5cbe3a05637fd7b9b07a8e5f4a41cb3
7
+ data.tar.gz: '060151482263dc869181d9ad369cd8e5b1aec32b126dd67e03a5365d59e45834751a21065ae9e725c2e1b8a977cddc75094d4b1917aa8cf1117c424d4b1e859d'
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ tags
11
11
  *.log
12
12
 
13
13
  .rake_tasks~
14
+ Gemfile.lock_
data/.release_history.yml CHANGED
@@ -6,3 +6,5 @@ git_cli:
6
6
  :timestamp: 1676968140.9885945
7
7
  - :version: 0.11.1
8
8
  :timestamp: 1676968358.595788
9
+ - :version: 0.11.2
10
+ :timestamp: 1676968433.2215726
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_cli (0.11.0)
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
- base58 (0.2.3)
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.20.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
- devops_assist
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
@@ -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
- if not st.success?
131
- raise CommitError, res
132
- else
133
- res
134
- end
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
- [true, res.strip!]
80
- else
81
- [false, res]
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
@@ -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,"a") do |f|
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
@@ -15,5 +15,5 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  module GitCli
18
- VERSION = "0.11.2"
18
+ VERSION = "0.11.3"
19
19
  end
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
- res = Antrapol::ToolRack::ProcessUtilsEngine.exec(path)
55
- if block
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.strip
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.2
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-02-21 00:00:00.000000000 Z
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: devops_assist
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.2.22
143
+ rubygems_version: 3.4.10
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: GIT command line interface