git_cli 0.2.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Rakefile +2 -0
- data/git_cli.gemspec +4 -0
- data/lib/git_cli.rb +3 -2
- data/lib/git_cli/add_commit.rb +10 -3
- data/lib/git_cli/delta.rb +36 -0
- data/lib/git_cli/git_core.rb +6 -18
- data/lib/git_cli/global.rb +8 -1
- data/lib/git_cli/version.rb +1 -1
- metadata +52 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5dffcd1329d4979a8b95a99ca22e8243b591a5101e235ccdeff850d43278fc2
|
4
|
+
data.tar.gz: 1a66a75d928f6fef50735465b24535281237ea057481ff8954cac09440daab0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dd8f01b20b6ddd46e3edfc2c8c1a61938642b1ccdec73e7941332144d4aba2730dd502a2becd2caaba307a0bcac22cd50f835c4b5d6e262a1bb29892c589dc9
|
7
|
+
data.tar.gz: 72bed6d4950e31b040a5b27ea72bca9597d350a55898efed658748d88e3bbf5d554f8e83e3daeaa3a16d03874396206dd85c86490ee5cfd42869fddcfe8ff4d0
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/git_cli.gemspec
CHANGED
@@ -29,4 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
|
30
30
|
spec.add_dependency "tlogger", "~> 0.21"
|
31
31
|
spec.add_dependency "toolrack", "~> 0.4.0"
|
32
|
+
spec.add_dependency "gvcs", "~> 0.1.0"
|
33
|
+
spec.add_dependency "ptools", "~> 1.4.0"
|
34
|
+
|
35
|
+
spec.add_development_dependency 'devops_helper', "~> 0.2.0"
|
32
36
|
end
|
data/lib/git_cli.rb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
|
17
17
|
require "git_cli/version"
|
18
18
|
|
19
|
+
require 'gvcs'
|
19
20
|
require 'toolrack'
|
20
21
|
|
21
22
|
require_relative "git_cli/git_core"
|
@@ -81,7 +82,7 @@ module GitCli
|
|
81
82
|
# version check
|
82
83
|
vst, tver = version
|
83
84
|
if vst
|
84
|
-
if (tver <=> MIN_GIT_VERSION) -1
|
85
|
+
if (tver <=> MIN_GIT_VERSION) == -1
|
85
86
|
log_warn("Min required version of GIT is #{MIN_GIT_VERSION}. System installed GIT is version #{tver}. The output might not be correct.")
|
86
87
|
end
|
87
88
|
|
@@ -89,7 +90,7 @@ module GitCli
|
|
89
90
|
end
|
90
91
|
|
91
92
|
end
|
92
|
-
end
|
93
|
+
end # Gvcs::Vcs
|
93
94
|
|
94
95
|
module WsCommon
|
95
96
|
def check_vcs
|
data/lib/git_cli/add_commit.rb
CHANGED
@@ -93,9 +93,11 @@ module GitCli
|
|
93
93
|
|
94
94
|
end # remove_from_vcs
|
95
95
|
|
96
|
-
def commit(message)
|
96
|
+
def commit(message, opts = { })
|
97
97
|
check_vcs
|
98
98
|
|
99
|
+
files = opts[:files] || []
|
100
|
+
[files] if not files.is_a?(Array)
|
99
101
|
# have to escape the message for command line purposes
|
100
102
|
msg = message.gsub("\"","\\\"").gsub("\\","\\\\")
|
101
103
|
|
@@ -105,6 +107,9 @@ module GitCli
|
|
105
107
|
cmd << "&&"
|
106
108
|
cmd << @vcs.exe_path
|
107
109
|
cmd << "commit"
|
110
|
+
if not_empty?(files)
|
111
|
+
cmd << files.join(" ")
|
112
|
+
end
|
108
113
|
cmd << "-m"
|
109
114
|
cmd << "\"#{msg}\""
|
110
115
|
|
@@ -116,7 +121,7 @@ module GitCli
|
|
116
121
|
[st.success?, res.strip]
|
117
122
|
end
|
118
123
|
|
119
|
-
end
|
124
|
+
end # commit
|
120
125
|
|
121
126
|
def commit_all(msg)
|
122
127
|
check_vcs
|
@@ -141,7 +146,9 @@ module GitCli
|
|
141
146
|
[st.success?, res.strip]
|
142
147
|
end
|
143
148
|
|
144
|
-
end
|
149
|
+
end # commit_all
|
150
|
+
|
151
|
+
|
145
152
|
|
146
153
|
end
|
147
154
|
end
|
data/lib/git_cli/delta.rb
CHANGED
@@ -52,6 +52,7 @@ module GitCli
|
|
52
52
|
cmd << @wsPath
|
53
53
|
cmd << "&&"
|
54
54
|
cmd << @vcs.exe_path
|
55
|
+
# list only non staged modifications
|
55
56
|
cmd << "diff --name-only --diff-filter=M"
|
56
57
|
|
57
58
|
cmdln = cmd.join(" ")
|
@@ -183,6 +184,41 @@ module GitCli
|
|
183
184
|
|
184
185
|
end # deleted_files
|
185
186
|
|
187
|
+
def staged_files
|
188
|
+
|
189
|
+
check_vcs
|
190
|
+
|
191
|
+
cmd = []
|
192
|
+
cmd << "cd"
|
193
|
+
cmd << @wsPath
|
194
|
+
cmd << "&&"
|
195
|
+
cmd << @vcs.exe_path
|
196
|
+
cmd << "diff --name-only --cached"
|
197
|
+
|
198
|
+
cmdln = cmd.join(" ")
|
199
|
+
log_debug "New Files : #{cmdln}"
|
200
|
+
dirs = []
|
201
|
+
files = []
|
202
|
+
res = os_exec(cmdln) do |st, res|
|
203
|
+
|
204
|
+
if st.success?
|
205
|
+
res.each_line do |l|
|
206
|
+
l.chomp!
|
207
|
+
if File.directory?(File.join(@wsPath,l))
|
208
|
+
dirs << l
|
209
|
+
else
|
210
|
+
files << l
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
[true, dirs.sort, files.sort]
|
215
|
+
else
|
216
|
+
[false, [], []]
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
end # staged_files
|
221
|
+
|
186
222
|
def reset_file_changes(path)
|
187
223
|
|
188
224
|
raise_if_empty(path, "Path cannot be empty for reset file changes operation", GitCliException)
|
data/lib/git_cli/git_core.rb
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
|
18
18
|
require_relative 'global'
|
19
19
|
|
20
|
+
require 'ptools'
|
21
|
+
|
20
22
|
module GitCli
|
21
23
|
module GitCore
|
22
24
|
|
@@ -58,25 +60,11 @@ module GitCli
|
|
58
60
|
private
|
59
61
|
def is_installed?
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
st, path = GitCli::OS::Linux::Utils.is_installed?("git")
|
65
|
-
GitCli::Global.instance.logger.debug "'git' install check return [#{st},#{path}]"
|
66
|
-
|
67
|
-
[st, path]
|
68
|
-
|
69
|
-
elsif Antrapol::ToolRack::RuntimeUtils.on_mac?
|
70
|
-
GitCli::Global.instance.logger.debug "Running on MacOS is detected"
|
71
|
-
require_relative 'os/macos/utils'
|
72
|
-
|
73
|
-
elsif Antrapol::ToolRack::RuntimeUtils.on_window?
|
74
|
-
GitCli::Global.instance.logger.debug "Running on MS Window is detected"
|
75
|
-
require_relative 'os/win/utils'
|
76
|
-
|
63
|
+
gpath = File.which('git')
|
64
|
+
if is_empty?(gpath)
|
65
|
+
[false, ""]
|
77
66
|
else
|
78
|
-
|
79
|
-
raise RuntimeError, "Unknown platform"
|
67
|
+
[true, gpath]
|
80
68
|
end
|
81
69
|
|
82
70
|
end # is_installed?
|
data/lib/git_cli/global.rb
CHANGED
@@ -24,8 +24,15 @@ module GitCli
|
|
24
24
|
|
25
25
|
attr_reader :logger
|
26
26
|
def initialize
|
27
|
-
|
27
|
+
debug = ENV['GitCli_Debug']
|
28
|
+
debugOut = ENV['GitCli_DebugOut'] || STDOUT
|
29
|
+
if debug.nil?
|
30
|
+
@logger = Tlogger.new('git_cli.log', 5, 1024*1024*10)
|
31
|
+
else
|
32
|
+
@logger = Tlogger.new(debugOut)
|
33
|
+
end
|
28
34
|
end
|
35
|
+
|
29
36
|
end
|
30
37
|
|
31
38
|
class GitCliException < StandardError; end
|
data/lib/git_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Liaw
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: tlogger
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - "~>"
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '0.21'
|
19
|
-
name: tlogger
|
20
|
-
prerelease: false
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.21'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: toolrack
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - "~>"
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 0.4.0
|
33
|
-
name: toolrack
|
34
|
-
prerelease: false
|
35
34
|
type: :runtime
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.4.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: gvcs
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ptools
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.4.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.4.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: devops_helper
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.2.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.2.0
|
41
83
|
description: Interface to GIT via command line interface instead of some sor of library
|
42
84
|
email:
|
43
85
|
- chrisliaw@antrapol.com
|
@@ -79,7 +121,7 @@ homepage: https://github.com/chrisliaw/git_cli
|
|
79
121
|
licenses:
|
80
122
|
- GPL-3.0
|
81
123
|
metadata: {}
|
82
|
-
post_install_message:
|
124
|
+
post_install_message:
|
83
125
|
rdoc_options: []
|
84
126
|
require_paths:
|
85
127
|
- lib
|
@@ -94,9 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
136
|
- !ruby/object:Gem::Version
|
95
137
|
version: '0'
|
96
138
|
requirements: []
|
97
|
-
|
98
|
-
|
99
|
-
signing_key:
|
139
|
+
rubygems_version: 3.1.2
|
140
|
+
signing_key:
|
100
141
|
specification_version: 4
|
101
142
|
summary: GIT command line interface
|
102
143
|
test_files: []
|