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