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 +4 -4
- data/.gitignore +1 -0
- data/.release_history.yml +4 -0
- data/.rspec +1 -0
- data/.version_history.yml +8 -0
- data/Gemfile +2 -0
- data/Rakefile +1 -1
- data/git_cli.gemspec +4 -2
- data/lib/git_cli/add_commit.rb +2 -2
- data/lib/git_cli/delta.rb +35 -0
- data/lib/git_cli/global.rb +4 -1
- data/lib/git_cli/ignore.rb +5 -2
- data/lib/git_cli/version.rb +1 -1
- data/lib/git_cli.rb +22 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77fb6b4308d34a185d9ba1355470893a53b15ee9710953ed0079c4847d8dc59d
|
4
|
+
data.tar.gz: 27d246f6554b2aa688738a38e21a2e985f8cbbb504d702f3ff0c0127ecd48949
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb96c8d437b6df087b875be71c70a8cea9f6d92bf5aac59c4a7fd1eeb3c756bcaccc4850ff1f4caa8e83f4a26a9c24a536122f0b37841ce16613ee571f90f92
|
7
|
+
data.tar.gz: 1cbfb647558fd5d0bb1b0909fb29aa02fe3f668c5796b5097d6d29c3b5f7c72b802a50f0640475a7482e0af379d49240058a1ca1183315f60f3a57645bc31de3
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
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
|
data/lib/git_cli/add_commit.rb
CHANGED
@@ -136,7 +136,7 @@ module GitCli
|
|
136
136
|
|
137
137
|
end # commit
|
138
138
|
|
139
|
-
def commit_all(
|
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
|
data/lib/git_cli/global.rb
CHANGED
@@ -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
|
data/lib/git_cli/ignore.rb
CHANGED
@@ -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
|
-
|
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"]
|
data/lib/git_cli/version.rb
CHANGED
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.
|
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:
|
11
|
+
date: 2023-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
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:
|
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
|