git_cli 0.3.0 → 0.8.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: ac7765b9c6015b83768c4901e1cc7bc7d1978d7a2015bb4190c93b7cc472b70d
4
- data.tar.gz: b39d29076885fcdad7b5c8449e53a933a8ba0faffe058321754045e0e418e29e
3
+ metadata.gz: 2137f01ad23cca0e4c523417ac601e30bb46f3eeeafd04d6e359b2d812452c9d
4
+ data.tar.gz: 7127ecfaf5f42a8fdd311864003c92529ce86dffc30211d212872ac23d92d92b
5
5
  SHA512:
6
- metadata.gz: fda641d636d8f3d2604deb9eceaaee1c2fa29310c04217779ec4af074555ca501ac7c0984e0b57e83a26ad32d1301af9dcba47b3759aa0ad56bbfb7e50b628af
7
- data.tar.gz: 04f0f5e7c1eb70c23c3155fb453e2f48fa58d778cc944155b1719c425d1732fe29b7c7b3d815d13801d575724f06580a835013bb47acd1e1c424a3a1012f6736
6
+ metadata.gz: fa62792074ef5f323dea781ca32dd2ae81e76775b8943c6eb5c6cf3310ad0a4506a72ecbf23f05f53803648ed29d4afc811e92e93d2b233353eb6cc3ee0dea08
7
+ data.tar.gz: 0b178d8eb671e405e16d5e6ba521d7aceb6765eaaa5c77e625e94465c1872def522a6aaf90304864c2910f5d8190236bb4eff5bbc75e0406ecbb83341b27662b
data/.gitignore CHANGED
@@ -8,3 +8,6 @@
8
8
  /tmp/
9
9
  Gemfile.lock
10
10
  tags
11
+ git_cli-0.1.0.gem
12
+ *.log
13
+
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
3
 
4
+ require "devops_helper"
5
+
4
6
  Rake::TestTask.new(:test) do |t|
5
7
  t.libs << "test"
6
8
  t.libs << "lib"
@@ -27,6 +27,10 @@ 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", "~> 0.21"
31
- spec.add_dependency "toolrack", "~> 0.4.0"
30
+ spec.add_dependency "tlogger", ">= 0.21"
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
@@ -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"
@@ -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
@@ -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
@@ -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)
@@ -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
- if Antrapol::ToolRack::RuntimeUtils.on_linux?
62
- require_relative 'os/linux/utils'
63
- GitCli::Global.instance.logger.debug "Running on Linux is detected"
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
- GitCli::Global.instance.logger.debug "Cannot determine which OS am i running...Confused"
79
- raise RuntimeError, "Unknown platform"
67
+ [true, gpath]
80
68
  end
81
69
 
82
70
  end # is_installed?
@@ -24,8 +24,15 @@ module GitCli
24
24
 
25
25
  attr_reader :logger
26
26
  def initialize
27
- @logger = Tlogger.new
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
@@ -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.3.0"
18
+ VERSION = "0.8.0"
19
19
  end
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.3.0
4
+ version: 0.8.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-10-31 00:00:00.000000000 Z
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
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
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
34
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
35
62
  type: :runtime
63
+ prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: 0.4.0
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
- rubyforge_project:
98
- rubygems_version: 2.7.10
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: []