git_cli 0.9.0 → 0.11.0

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: 63fdc22895e48a0005e1fcaf0e5dc2291c6fdc26019ae566f1009424d083292c
4
- data.tar.gz: 5e602e81ea3b378e185add93c6d8fb1ea97c48fc600c784c2e22aaa43beb0e21
3
+ metadata.gz: 77fb6b4308d34a185d9ba1355470893a53b15ee9710953ed0079c4847d8dc59d
4
+ data.tar.gz: 27d246f6554b2aa688738a38e21a2e985f8cbbb504d702f3ff0c0127ecd48949
5
5
  SHA512:
6
- metadata.gz: a05ced2c8d7ec7b8efcc69ec6d1f41b80e11fbc5b3f1c1f5e7954800fd594d0d98aae0050ebab902d101ee7a7a653a2a989744f77bb7710aba367a10f3cf8719
7
- data.tar.gz: e4a85fb3684d6b2377bf57ccd1e8e9c7c5b931997e22d1052c24de2a9c21d4792ff5c455e72e63d9e79fd9df863470b28bbb9e07dd8e6ea0e8ec5f29164f9901
6
+ metadata.gz: bfb96c8d437b6df087b875be71c70a8cea9f6d92bf5aac59c4a7fd1eeb3c756bcaccc4850ff1f4caa8e83f4a26a9c24a536122f0b37841ce16613ee571f90f92
7
+ data.tar.gz: 1cbfb647558fd5d0bb1b0909fb29aa02fe3f668c5796b5097d6d29c3b5f7c72b802a50f0640475a7482e0af379d49240058a1ca1183315f60f3a57645bc31de3
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ tags
11
11
  git_cli-0.1.0.gem
12
12
  *.log
13
13
 
14
+ .rake_tasks~
@@ -0,0 +1,4 @@
1
+ ---
2
+ git_cli:
3
+ - :version: 0.10.0
4
+ :timestamp: 1661971875.794398
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,8 @@
1
+ ---
2
+ git_cli:
3
+ - :version: 0.7.0
4
+ :created_at: 2020-12-07 23:01:04.252722927 +08:00
5
+ - :version: 0.8.0
6
+ :created_at: 2020-12-07 23:14:58.685361227 +08:00
7
+ - :version: 0.9.0
8
+ :created_at: 2021-10-22 23:01:48.298477606 +08:00
data/Gemfile CHANGED
@@ -5,3 +5,5 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.0"
8
+
9
+ gem 'gvcs', git: 'gvcs', branch: 'master'
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
- require "devops_helper"
4
+ require "devops_assist"
5
5
 
6
6
  Rake::TestTask.new(:test) do |t|
7
7
  t.libs << "test"
data/git_cli.gemspec CHANGED
@@ -27,10 +27,12 @@ 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"
30
+ #spec.add_dependency "tlogger"
31
+ spec.add_dependency 'teLogger'
31
32
  spec.add_dependency "toolrack"
32
33
  spec.add_dependency "gvcs"
33
34
  spec.add_dependency "ptools", "~> 1.4.0"
34
35
 
35
- spec.add_development_dependency 'devops_helper' #, ">= 0.2.0"
36
+ #spec.add_development_dependency 'devops_helper' #, ">= 0.2.0"
37
+ spec.add_development_dependency 'devops_assist' #, ">= 0.2.0"
36
38
  end
@@ -136,7 +136,7 @@ module GitCli
136
136
 
137
137
  end # commit
138
138
 
139
- def commit_all(msg)
139
+ def commit_all(message)
140
140
  check_vcs
141
141
 
142
142
  # have to escape the message for command line purposes
@@ -149,7 +149,7 @@ module GitCli
149
149
  cmd << @vcs.exe_path
150
150
  cmd << "commit"
151
151
  cmd << "-am"
152
- cmd << msg
152
+ cmd << "\"#{msg}\""
153
153
 
154
154
  cmdln = cmd.join " "
155
155
 
data/lib/git_cli/delta.rb CHANGED
@@ -367,6 +367,41 @@ module GitCli
367
367
 
368
368
  end # reset all changes
369
369
 
370
+ # If remote is ahead of local
371
+ # git rev-list HEAD..origin/main --count
372
+ #
373
+ # if local is ahead of remote
374
+ # git rev-list origin/main..HEAD --count
375
+ #
376
+ def calculate_distance(from, to)
377
+
378
+ check_vcs
379
+
380
+ cmd = []
381
+ cmd << "cd"
382
+ cmd << @wsPath
383
+ cmd << "&&"
384
+ cmd << @vcs.exe_path
385
+ cmd << "rev-list #{from}..#{to} --count"
386
+
387
+ cmdln = cmd.join(" ")
388
+ log_debug "Calculate distance between two repos : #{cmdln}"
389
+ res = os_exec(cmdln) do |st, res|
390
+ [st.success?, res]
391
+ end
392
+
393
+ end
394
+
395
+ def is_local_ahead_of_remote?(remote_name, branch = "main")
396
+
397
+ calculate_distance("#{remote_name}/#{branch}", "HEAD")
398
+
399
+ end
400
+
401
+ def is_remote_ahead_of_local?(remote_name, branch = "main")
402
+
403
+ calculate_distance("HEAD","#{remote_name}/#{branch}")
404
+ end
370
405
 
371
406
  end
372
407
  end
@@ -15,9 +15,12 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
 
18
- require 'tlogger'
18
+ #require 'tlogger'
19
+ require 'teLogger'
19
20
  require 'singleton'
20
21
 
22
+ include TeLogger
23
+
21
24
  module GitCli
22
25
  class Global
23
26
  include Singleton
@@ -19,9 +19,12 @@
19
19
  module GitCli
20
20
  module Ignore
21
21
 
22
- def ignore(val)
22
+ def ignore(*val)
23
23
  with_ignore_file do |f|
24
- f.puts val
24
+ val.each do |v|
25
+ f.puts v
26
+ end
27
+ #f.puts val
25
28
  end
26
29
  log_debug ".gitignore file updated with line '#{val}'"
27
30
  [true,".gitignore file updated"]
@@ -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.9.0"
18
+ VERSION = "0.11.0"
19
19
  end
data/lib/git_cli.rb CHANGED
@@ -46,6 +46,9 @@ module GitCli
46
46
  include Antrapol::ToolRack::ExceptionUtils
47
47
 
48
48
  def os_exec(path, &block)
49
+
50
+ Gvcs::Config.instance.command_output.puts("Git command : #{path}") if Gvcs::Config.instance.is_show_vcs_command?
51
+
49
52
  # redirect stderr to stdout
50
53
  path = "#{path} 2>&1"
51
54
  res = Antrapol::ToolRack::ProcessUtilsEngine.exec(path)
@@ -221,6 +224,23 @@ module GitCli
221
224
  end
222
225
  end
223
226
 
227
+ def repos
228
+ if @repos.nil? or @repos.empty?
229
+ load_remote_to_repos
230
+ end
231
+ @repos
232
+ end
233
+
234
+ def is_clean?
235
+ nd, nf = new_files
236
+ md, mf = modified_files
237
+ dd, df = deleted_files
238
+ sd, sf = staged_files
239
+
240
+ (nd.length == 0 and nf.length == 0 and md.length == 0 and mf.length == 0 and dd.length == 0 and df.length == 0 and sd.length == 0 and sf.length == 0)
241
+ end
242
+ alias_method :clean?, :is_clean?
243
+
224
244
  end # Gvcs::Workspace
225
245
 
226
246
 
@@ -249,6 +269,7 @@ module GitCli
249
269
  def is_fetch_supported?
250
270
  @fetch
251
271
  end
272
+ alias_method :can_fetch?, :is_fetch_supported?
252
273
 
253
274
  def support_push
254
275
  @push = true
@@ -256,6 +277,7 @@ module GitCli
256
277
  def is_push_supported?
257
278
  @push
258
279
  end
280
+ alias_method :can_push?, :is_push_supported?
259
281
 
260
282
  end # repository
261
283
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.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: 2021-10-22 00:00:00.000000000 Z
11
+ date: 2023-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: tlogger
14
+ name: teLogger
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -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_helper
70
+ name: devops_assist
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -88,7 +88,10 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - ".gitignore"
91
+ - ".release_history.yml"
92
+ - ".rspec"
91
93
  - ".travis.yml"
94
+ - ".version_history.yml"
92
95
  - CODE_OF_CONDUCT.md
93
96
  - Gemfile
94
97
  - LICENSE.txt