raykit 0.0.483 → 0.0.485

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +20 -20
  4. data/bin/raykit +6 -6
  5. data/lib/raykit/auto_setup.rb +43 -43
  6. data/lib/raykit/command.rb +341 -341
  7. data/lib/raykit/conan/buildinfo.rb +69 -69
  8. data/lib/raykit/conanpackage.rb +49 -49
  9. data/lib/raykit/console.rb +272 -272
  10. data/lib/raykit/default_content.rb +227 -227
  11. data/lib/raykit/dir.rb +49 -49
  12. data/lib/raykit/dotnet.rb +176 -174
  13. data/lib/raykit/environment.rb +109 -109
  14. data/lib/raykit/filesystem.rb +34 -34
  15. data/lib/raykit/git/commit.rb +16 -16
  16. data/lib/raykit/git/directory.rb +216 -216
  17. data/lib/raykit/git/files.rb +46 -46
  18. data/lib/raykit/git/repositories.rb +89 -89
  19. data/lib/raykit/git/repository.rb +244 -244
  20. data/lib/raykit/installer.rb +17 -17
  21. data/lib/raykit/log.rb +80 -80
  22. data/lib/raykit/logevent.rb +49 -49
  23. data/lib/raykit/logging.rb +57 -57
  24. data/lib/raykit/markdown.rb +21 -21
  25. data/lib/raykit/msbuild.rb +54 -54
  26. data/lib/raykit/nugetpackage.rb +54 -54
  27. data/lib/raykit/nunit.rb +13 -13
  28. data/lib/raykit/project.rb +339 -339
  29. data/lib/raykit/rake.rb +39 -39
  30. data/lib/raykit/runner.rb +42 -42
  31. data/lib/raykit/secrets.rb +38 -38
  32. data/lib/raykit/sourceImport.rb +74 -74
  33. data/lib/raykit/sourceImports.rb +43 -43
  34. data/lib/raykit/string.rb +18 -18
  35. data/lib/raykit/tasks.rb +99 -99
  36. data/lib/raykit/text.rb +32 -32
  37. data/lib/raykit/timer.rb +31 -31
  38. data/lib/raykit/version.rb +103 -103
  39. data/lib/raykit/vstest.rb +24 -24
  40. data/lib/raykit/wt.rb +28 -28
  41. data/lib/raykit/zip.rb +73 -73
  42. data/lib/raykit.rb +125 -125
  43. metadata +2 -2
@@ -1,339 +1,339 @@
1
- # frozen_string_literal: true
2
-
3
- require "rake/clean"
4
- require "digest"
5
-
6
- module Raykit
7
- class Project
8
- attr_accessor :name, :description, :version, :timer, :verbose, :target
9
-
10
- @directory
11
- #@version
12
- @remote
13
- @repository
14
- @git_directory
15
- @timeout
16
- @values
17
- @commands
18
-
19
- # @log
20
- # @commit_message_filename
21
-
22
- # TODO: refactor to remove the defaults
23
- def initialize(name = "", description = "", version = "")
24
- @description = description if description.length.positive?
25
- @version = version if version.length.positive?
26
- @timeout = 1000 * 60 * 15
27
- @verbose = false
28
- @timer = Raykit::Timer.new
29
- @remote = ""
30
- @commit_message_filename = "commit_message.tmp"
31
- if Dir.exist?(RAKE_DIRECTORY)
32
- @directory = RAKE_DIRECTORY
33
- if Dir.exist?("#{RAKE_DIRECTORY}/.git") && Dir.exist?(@directory)
34
- @git_directory = Raykit::Git::Directory.new(@directory)
35
- @remote = @git_directory.remote
36
- end
37
- else
38
- @directory = ""
39
- end
40
-
41
- # @log=Log.new("#{RAKE_DIRECTORY}/tmp/raykit.log")
42
- if (name.length.positive?)
43
- @name = name
44
- else
45
- if defined?(NAME)
46
- @name = NAME
47
- else
48
- slns = Dir.glob("*.sln")
49
- if slns.length == 1
50
- @name = slns[0].gsub(".sln", "")
51
- else
52
- gemspecs = Dir.glob("*.gemspec")
53
- if gemspecs.length == 1
54
- @name = gemspecs[0].gsub(".gemspec", "")
55
- else
56
- remote_parts = @remote.split("/")
57
- @name = remote_parts[-1].gsub(".git", "") if remote_parts.length.positive?
58
- end
59
- end
60
- end
61
- end
62
-
63
- if version.length.zero?
64
- if defined?(VERSION)
65
- @version = VERSION
66
- else
67
- @version = Raykit::Version.detect(@name, true)
68
- end
69
- end
70
-
71
- if description.length.zero?
72
- @description = DESCRIPTION if defined?(DESCRIPTION)
73
- end
74
-
75
- @repository = Raykit::Git::Repository.new(@remote)
76
- @values = Hash::new()
77
- @commands = Array::new()
78
- end
79
-
80
- def get_dev_dir(subdir)
81
- Raykit::Environment.get_dev_dir(subdir)
82
- end
83
-
84
- attr_reader :log, :directory, :remote
85
-
86
- # def target
87
- # @target
88
- # end
89
- def target_md5
90
- return Digest::MD5.file(target).to_s.strip if !target.nil? && File.exist?(target)
91
-
92
- ""
93
- end
94
-
95
- def branch
96
- return "main" if @git_directory.nil?
97
- @git_directory.branch
98
- end
99
-
100
- def values
101
- @values
102
- end
103
-
104
- # latest local commit
105
- def latest_commit
106
- return "" if detached?
107
- Dir.chdir(@directory) do
108
- text = `git log -n 1`
109
- scan = text.scan(/commit (\w+)\s/)
110
- return scan[0][0].to_s
111
- end
112
- end
113
-
114
- def outstanding_commit?
115
- Dir.chdir(@directory) do
116
- return true unless `git status`.include?("nothing to commit")
117
- end
118
- false
119
- end
120
-
121
- def outstanding_tag?
122
- # puts `git log -n 1`
123
- # !latest_tag_commit.eql?(latest_commit)
124
- # commit 2e4cb6d6c0721e16cd06afee85b7cdc27354921b (HEAD -> master, tag: 0.0.180, origin/master, origin/HEAD)
125
- outstanding_commit? || !`git log -n 1`.include?("tag:")
126
- end
127
-
128
- def read_only?
129
- return true if !File.exist?(".git") || detached?
130
- return false
131
- end
132
-
133
- def detached?
134
- return true if @git_directory.nil?
135
- @git_directory.detached?
136
- end
137
-
138
- def has_diff?(filename)
139
- Dir.chdir(@directory) do
140
- text = `git diff #{filename}`.strip
141
- return true if text.length.positive?
142
- end
143
- end
144
-
145
- def set_version(version)
146
- @version = version
147
- end
148
-
149
- def latest_tag
150
- `git describe --abbrev=0`.strip
151
- end
152
-
153
- def latest_tag_commit
154
- `git show-ref -s #{latest_tag}`.strip
155
- end
156
-
157
- def latest_tag_md5
158
- text = `git tag #{latest_tag} -n3`
159
- scan = text.scan(/md5=(\w{32})/)
160
- return scan[0][0].to_s.strip if scan.length.positive? && scan[0].length.positive?
161
-
162
- ""
163
- end
164
-
165
- def last_modified_filename
166
- Dir.chdir(@directory) do
167
- Dir.glob("**/*.*").select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
168
- end
169
- end
170
-
171
- def size
172
- Dir.chdir(@directory) do
173
- text = `git count-objects -v -H`
174
- if matches = text.match(/size: ([. \w]+)$/)
175
- matches[1]
176
- else
177
- text
178
- end
179
- end
180
- end
181
-
182
- def size_pack
183
- Dir.chdir(@directory) do
184
- text = `git count-objects -v -H`
185
- if matches = text.match(/size-pack: ([. \w]+)$/)
186
- matches[1]
187
- else
188
- text
189
- end
190
- end
191
- end
192
-
193
- def elapsed
194
- elapsed = @timer.elapsed
195
- if elapsed < 1.0
196
- "#{format("%.1f", @timer.elapsed)}s"
197
- else
198
- "#{format("%.0f", @timer.elapsed)}s"
199
- end
200
- end
201
-
202
- def info
203
- ljust = 35
204
- puts ""
205
- puts "PROJECT.name".ljust(ljust) + Rainbow(PROJECT.name).yellow.bright
206
- puts "PROJECT.version".ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
207
- puts "PROJECT.remote".ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
208
- puts "PROJECT.branch".ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright
209
- puts "PROJECT.detached?".ljust(ljust) + Rainbow(PROJECT.detached?).yellow.bright
210
- # puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
211
- # puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
212
- puts "PROJECT.latest_tag".ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
213
- puts "PROJECT.latest_tag_commit".ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
214
- puts "PROJECT.latest_tag_md5".ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
215
- puts "PROJECT.latest_commit".ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
216
- puts "PROJECT.last_modified_filename".ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
217
- # puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
218
- puts "PROJECT.size".ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
219
- puts "PROJECT.size_pack".ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
220
- puts "PROJECT.outstanding_commit?".ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
221
- puts "PROJECT.outstanding_tag?".ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
222
- puts ""
223
- self
224
- end
225
-
226
- def to_markdown()
227
- md = "# #{@name}"
228
- md += get_markdown_nvp("Name", "Value", " ")
229
- md += get_markdown_nvp("-", "-", "-")
230
- md += get_markdown_nvp("Version", "#{@version}", " ")
231
- md += get_markdown_nvp("Machine", "#{Raykit::Environment::machine}", " ")
232
- md += get_markdown_nvp("User", "#{Raykit::Environment::user}", " ")
233
- @values.each do |key, value|
234
- md += get_markdown_nvp(key, value, " ")
235
- end
236
- @commands.each do |cmd|
237
- md = md + "\n" + cmd.to_markdown
238
- end
239
- md
240
- end
241
-
242
- def get_markdown_nvp(key, value, pad_char)
243
- "\n| " + key.to_s.ljust(36, pad_char) + "| " + value.to_s.ljust(36, pad_char)
244
- end
245
-
246
- def summary
247
- info if @verbose
248
- puts "[#{elapsed}] #{Rainbow(@name).yellow.bright} #{Rainbow(version).yellow.bright}"
249
- end
250
-
251
- def commit_message_filename
252
- warn "[DEPRECATION] 'commit_message_filename' is deprecated."
253
- @commit_message_filename
254
- end
255
-
256
- def commit(commit_message)
257
- warn "[DEPRECATION] 'commit_message_filename' is deprecated. Use a run command for better transparency."
258
- Dir.chdir(@directory) do
259
- if File.exist?(".gitignore")
260
- status = `git status`
261
- if status.include?("Changes not staged for commit:")
262
- run("git add --all")
263
- if GIT_DIRECTORY.outstanding_commit?
264
- if File.exist?(@commit_message_filename)
265
- run("git commit --file #{@commit_message_filename}")
266
- File.delete(@commit_message_filename)
267
- else
268
- run("git commit -m'#{commit_message}'")
269
- end
270
- end
271
- end
272
- else
273
- puts "warning: .gitignore not found."
274
- end
275
- end
276
- self
277
- end
278
-
279
- def push
280
- Dir.chdir(@directory) do
281
- status = `git status`
282
- if status.include?('use "git push"')
283
- run("git push")
284
- end
285
- end
286
- self
287
- end
288
-
289
- def pull
290
- Dir.chdir(@directory) do
291
- run("git pull")
292
- end
293
- self
294
- end
295
-
296
- def tag
297
- warn "[DEPRECATION] 'tag' is deprecated. Use run command(s) for better transparency."
298
- Dir.chdir(@directory) do
299
- specific_tag = `git tag -l #{@version}`.strip
300
- puts Rainbow("git tag - #{@version}").green if @verbose
301
- puts `git tag -l #{@version}` if @verbose
302
- if specific_tag.length.zero?
303
- puts "tag #{@version} not detected." if @verbose
304
- tag = `git describe --abbrev=0 --tags`.strip
305
- if @version != tag
306
- puts "latest tag #{@tag}" if @verbose
307
- run("git tag #{@version} -m'#{@version}'")
308
- run("git push origin #{@version}")
309
- # push
310
- end
311
- elsif @verbose
312
- puts "already has tag #{specific_tag}"
313
- end
314
- end
315
- self
316
- end
317
-
318
- def run(command, quit_on_failure = true)
319
- if command.is_a?(Array)
320
- command.each { |subcommand| run(subcommand, quit_on_failure) }
321
- else
322
- cmd = Command.new(command).set_timeout(@timeout).run
323
- cmd.summary
324
- elapsed_str = Timer.get_elapsed_str(cmd.elapsed, 0)
325
- if !cmd.exitstatus.nil? && cmd.exitstatus.zero?
326
- else
327
- # display error details
328
- cmd.details
329
- if quit_on_failure
330
- abort
331
- end
332
- end
333
- cmd.save
334
- @commands << cmd
335
- cmd
336
- end
337
- end
338
- end
339
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/clean"
4
+ require "digest"
5
+
6
+ module Raykit
7
+ class Project
8
+ attr_accessor :name, :description, :version, :timer, :verbose, :target
9
+
10
+ @directory
11
+ #@version
12
+ @remote
13
+ @repository
14
+ @git_directory
15
+ @timeout
16
+ @values
17
+ @commands
18
+
19
+ # @log
20
+ # @commit_message_filename
21
+
22
+ # TODO: refactor to remove the defaults
23
+ def initialize(name = "", description = "", version = "")
24
+ @description = description if description.length.positive?
25
+ @version = version if version.length.positive?
26
+ @timeout = 1000 * 60 * 15
27
+ @verbose = false
28
+ @timer = Raykit::Timer.new
29
+ @remote = ""
30
+ @commit_message_filename = "commit_message.tmp"
31
+ if Dir.exist?(RAKE_DIRECTORY)
32
+ @directory = RAKE_DIRECTORY
33
+ if Dir.exist?("#{RAKE_DIRECTORY}/.git") && Dir.exist?(@directory)
34
+ @git_directory = Raykit::Git::Directory.new(@directory)
35
+ @remote = @git_directory.remote
36
+ end
37
+ else
38
+ @directory = ""
39
+ end
40
+
41
+ # @log=Log.new("#{RAKE_DIRECTORY}/tmp/raykit.log")
42
+ if (name.length.positive?)
43
+ @name = name
44
+ else
45
+ if defined?(NAME)
46
+ @name = NAME
47
+ else
48
+ slns = Dir.glob("*.sln")
49
+ if slns.length == 1
50
+ @name = slns[0].gsub(".sln", "")
51
+ else
52
+ gemspecs = Dir.glob("*.gemspec")
53
+ if gemspecs.length == 1
54
+ @name = gemspecs[0].gsub(".gemspec", "")
55
+ else
56
+ remote_parts = @remote.split("/")
57
+ @name = remote_parts[-1].gsub(".git", "") if remote_parts.length.positive?
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ if version.length.zero?
64
+ if defined?(VERSION)
65
+ @version = VERSION
66
+ else
67
+ @version = Raykit::Version.detect(@name, true)
68
+ end
69
+ end
70
+
71
+ if description.length.zero?
72
+ @description = DESCRIPTION if defined?(DESCRIPTION)
73
+ end
74
+
75
+ @repository = Raykit::Git::Repository.new(@remote)
76
+ @values = Hash::new()
77
+ @commands = Array::new()
78
+ end
79
+
80
+ def get_dev_dir(subdir)
81
+ Raykit::Environment.get_dev_dir(subdir)
82
+ end
83
+
84
+ attr_reader :log, :directory, :remote
85
+
86
+ # def target
87
+ # @target
88
+ # end
89
+ def target_md5
90
+ return Digest::MD5.file(target).to_s.strip if !target.nil? && File.exist?(target)
91
+
92
+ ""
93
+ end
94
+
95
+ def branch
96
+ return "main" if @git_directory.nil?
97
+ @git_directory.branch
98
+ end
99
+
100
+ def values
101
+ @values
102
+ end
103
+
104
+ # latest local commit
105
+ def latest_commit
106
+ return "" if detached?
107
+ Dir.chdir(@directory) do
108
+ text = `git log -n 1`
109
+ scan = text.scan(/commit (\w+)\s/)
110
+ return scan[0][0].to_s
111
+ end
112
+ end
113
+
114
+ def outstanding_commit?
115
+ Dir.chdir(@directory) do
116
+ return true unless `git status`.include?("nothing to commit")
117
+ end
118
+ false
119
+ end
120
+
121
+ def outstanding_tag?
122
+ # puts `git log -n 1`
123
+ # !latest_tag_commit.eql?(latest_commit)
124
+ # commit 2e4cb6d6c0721e16cd06afee85b7cdc27354921b (HEAD -> master, tag: 0.0.180, origin/master, origin/HEAD)
125
+ outstanding_commit? || !`git log -n 1`.include?("tag:")
126
+ end
127
+
128
+ def read_only?
129
+ return true if !File.exist?(".git") || detached?
130
+ return false
131
+ end
132
+
133
+ def detached?
134
+ return true if @git_directory.nil?
135
+ @git_directory.detached?
136
+ end
137
+
138
+ def has_diff?(filename)
139
+ Dir.chdir(@directory) do
140
+ text = `git diff #{filename}`.strip
141
+ return true if text.length.positive?
142
+ end
143
+ end
144
+
145
+ def set_version(version)
146
+ @version = version
147
+ end
148
+
149
+ def latest_tag
150
+ `git describe --abbrev=0`.strip
151
+ end
152
+
153
+ def latest_tag_commit
154
+ `git show-ref -s #{latest_tag}`.strip
155
+ end
156
+
157
+ def latest_tag_md5
158
+ text = `git tag #{latest_tag} -n3`
159
+ scan = text.scan(/md5=(\w{32})/)
160
+ return scan[0][0].to_s.strip if scan.length.positive? && scan[0].length.positive?
161
+
162
+ ""
163
+ end
164
+
165
+ def last_modified_filename
166
+ Dir.chdir(@directory) do
167
+ Dir.glob("**/*.*").select { |f| File.file?(f) }.max_by { |f| File.mtime(f) }
168
+ end
169
+ end
170
+
171
+ def size
172
+ Dir.chdir(@directory) do
173
+ text = `git count-objects -v -H`
174
+ if matches = text.match(/size: ([. \w]+)$/)
175
+ matches[1]
176
+ else
177
+ text
178
+ end
179
+ end
180
+ end
181
+
182
+ def size_pack
183
+ Dir.chdir(@directory) do
184
+ text = `git count-objects -v -H`
185
+ if matches = text.match(/size-pack: ([. \w]+)$/)
186
+ matches[1]
187
+ else
188
+ text
189
+ end
190
+ end
191
+ end
192
+
193
+ def elapsed
194
+ elapsed = @timer.elapsed
195
+ if elapsed < 1.0
196
+ "#{format("%.1f", @timer.elapsed)}s"
197
+ else
198
+ "#{format("%.0f", @timer.elapsed)}s"
199
+ end
200
+ end
201
+
202
+ def info
203
+ ljust = 35
204
+ puts ""
205
+ puts "PROJECT.name".ljust(ljust) + Rainbow(PROJECT.name).yellow.bright
206
+ puts "PROJECT.version".ljust(ljust) + Rainbow(PROJECT.version).yellow.bright
207
+ puts "PROJECT.remote".ljust(ljust) + Rainbow(PROJECT.remote).yellow.bright
208
+ puts "PROJECT.branch".ljust(ljust) + Rainbow(PROJECT.branch).yellow.bright
209
+ puts "PROJECT.detached?".ljust(ljust) + Rainbow(PROJECT.detached?).yellow.bright
210
+ # puts "PROJECT.target".ljust(ljust) + Rainbow(PROJECT.target).yellow.bright
211
+ # puts "PROJECT.target_md5".ljust(ljust) + Rainbow(PROJECT.target_md5).yellow.bright
212
+ puts "PROJECT.latest_tag".ljust(ljust) + Rainbow(PROJECT.latest_tag).yellow.bright
213
+ puts "PROJECT.latest_tag_commit".ljust(ljust) + Rainbow(PROJECT.latest_tag_commit).yellow.bright
214
+ puts "PROJECT.latest_tag_md5".ljust(ljust) + Rainbow(PROJECT.latest_tag_md5).yellow.bright
215
+ puts "PROJECT.latest_commit".ljust(ljust) + Rainbow(PROJECT.latest_commit).yellow.bright
216
+ puts "PROJECT.last_modified_filename".ljust(ljust) + Rainbow(PROJECT.last_modified_filename).yellow.bright
217
+ # puts "PROJECT.elapsed".ljust(ljust) + Rainbow(PROJECT.elapsed).yellow.bright
218
+ puts "PROJECT.size".ljust(ljust) + Rainbow(PROJECT.size).yellow.bright
219
+ puts "PROJECT.size_pack".ljust(ljust) + Rainbow(PROJECT.size_pack).yellow.bright
220
+ puts "PROJECT.outstanding_commit?".ljust(ljust) + Rainbow(PROJECT.outstanding_commit?).yellow.bright
221
+ puts "PROJECT.outstanding_tag?".ljust(ljust) + Rainbow(PROJECT.outstanding_tag?).yellow.bright
222
+ puts ""
223
+ self
224
+ end
225
+
226
+ def to_markdown()
227
+ md = "# #{@name}"
228
+ md += get_markdown_nvp("Name", "Value", " ")
229
+ md += get_markdown_nvp("-", "-", "-")
230
+ md += get_markdown_nvp("Version", "#{@version}", " ")
231
+ md += get_markdown_nvp("Machine", "#{Raykit::Environment::machine}", " ")
232
+ md += get_markdown_nvp("User", "#{Raykit::Environment::user}", " ")
233
+ @values.each do |key, value|
234
+ md += get_markdown_nvp(key, value, " ")
235
+ end
236
+ @commands.each do |cmd|
237
+ md = md + "\n" + cmd.to_markdown
238
+ end
239
+ md
240
+ end
241
+
242
+ def get_markdown_nvp(key, value, pad_char)
243
+ "\n| " + key.to_s.ljust(36, pad_char) + "| " + value.to_s.ljust(36, pad_char)
244
+ end
245
+
246
+ def summary
247
+ info if @verbose
248
+ puts "[#{elapsed}] #{Rainbow(@name).yellow.bright} #{Rainbow(version).yellow.bright}"
249
+ end
250
+
251
+ def commit_message_filename
252
+ warn "[DEPRECATION] 'commit_message_filename' is deprecated."
253
+ @commit_message_filename
254
+ end
255
+
256
+ def commit(commit_message)
257
+ warn "[DEPRECATION] 'commit_message_filename' is deprecated. Use a run command for better transparency."
258
+ Dir.chdir(@directory) do
259
+ if File.exist?(".gitignore")
260
+ status = `git status`
261
+ if status.include?("Changes not staged for commit:")
262
+ run("git add --all")
263
+ if GIT_DIRECTORY.outstanding_commit?
264
+ if File.exist?(@commit_message_filename)
265
+ run("git commit --file #{@commit_message_filename}")
266
+ File.delete(@commit_message_filename)
267
+ else
268
+ run("git commit -m'#{commit_message}'")
269
+ end
270
+ end
271
+ end
272
+ else
273
+ puts "warning: .gitignore not found."
274
+ end
275
+ end
276
+ self
277
+ end
278
+
279
+ def push
280
+ Dir.chdir(@directory) do
281
+ status = `git status`
282
+ if status.include?('use "git push"')
283
+ run("git push")
284
+ end
285
+ end
286
+ self
287
+ end
288
+
289
+ def pull
290
+ Dir.chdir(@directory) do
291
+ run("git pull")
292
+ end
293
+ self
294
+ end
295
+
296
+ def tag
297
+ warn "[DEPRECATION] 'tag' is deprecated. Use run command(s) for better transparency."
298
+ Dir.chdir(@directory) do
299
+ specific_tag = `git tag -l #{@version}`.strip
300
+ puts Rainbow("git tag - #{@version}").green if @verbose
301
+ puts `git tag -l #{@version}` if @verbose
302
+ if specific_tag.length.zero?
303
+ puts "tag #{@version} not detected." if @verbose
304
+ tag = `git describe --abbrev=0 --tags`.strip
305
+ if @version != tag
306
+ puts "latest tag #{@tag}" if @verbose
307
+ run("git tag #{@version} -m'#{@version}'")
308
+ run("git push origin #{@version}")
309
+ # push
310
+ end
311
+ elsif @verbose
312
+ puts "already has tag #{specific_tag}"
313
+ end
314
+ end
315
+ self
316
+ end
317
+
318
+ def run(command, quit_on_failure = true)
319
+ if command.is_a?(Array)
320
+ command.each { |subcommand| run(subcommand, quit_on_failure) }
321
+ else
322
+ cmd = Command.new(command).set_timeout(@timeout).run
323
+ cmd.summary
324
+ elapsed_str = Timer.get_elapsed_str(cmd.elapsed, 0)
325
+ if !cmd.exitstatus.nil? && cmd.exitstatus.zero?
326
+ else
327
+ # display error details
328
+ cmd.details
329
+ if quit_on_failure
330
+ abort
331
+ end
332
+ end
333
+ cmd.save
334
+ @commands << cmd
335
+ cmd
336
+ end
337
+ end
338
+ end
339
+ end