release-gem 0.1.30 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -7
- data/lib/release/gem/cli.rb +16 -0
- data/lib/release/gem/gem_action.rb +44 -30
- data/lib/release/gem/gem_cli_action.rb +35 -10
- data/lib/release/gem/vcs_action.rb +208 -178
- data/lib/release/gem/vcs_cli_action.rb +159 -53
- data/lib/release/gem/version.rb +1 -1
- data/lib/release/gem.rb +40 -7
- data/templates/standard_cli_flow.rb +6 -3
- metadata +41 -26
@@ -26,50 +26,81 @@ module Release
|
|
26
26
|
instance_eval(&block) if block
|
27
27
|
end
|
28
28
|
|
29
|
+
def has_staged_file?
|
30
|
+
stgDir, stgFiles = @ws.staged_files
|
31
|
+
not_empty?(stgDir) or not_empty?(stgFiles)
|
32
|
+
end
|
33
|
+
|
34
|
+
def has_new_files?
|
35
|
+
newDir, newFiles = @ws.new_files
|
36
|
+
not_empty?(newDir) or not_empty?(newFiles)
|
37
|
+
end
|
38
|
+
|
39
|
+
def has_modified_files?
|
40
|
+
modDir, modFiles = @ws.modified_files
|
41
|
+
not_empty?(modDir) or not_empty?(modFiles)
|
42
|
+
end
|
43
|
+
|
44
|
+
def has_deleted_files?
|
45
|
+
delDir, delFiles = @ws.deleted_files
|
46
|
+
not_empty?(delDir) or not_empty?(delFiles)
|
47
|
+
end
|
48
|
+
|
49
|
+
def overview(&block)
|
50
|
+
raise VcsActionError, "block is required" if not block
|
51
|
+
|
52
|
+
stgDir, stgFiles = @ws.staged_files
|
53
|
+
modDir, modFiles = @ws.modified_files
|
54
|
+
newDir, newFiles = @ws.new_files
|
55
|
+
delDir, delFiles = @ws.deleted_files
|
56
|
+
|
57
|
+
modFiles.delete_if { |f| stgFiles.include?(f) }
|
58
|
+
modDir.delete_if { |f| stgDir.include?(f) }
|
59
|
+
|
60
|
+
newFiles.delete_if { |f| stgFiles.include?(f) }
|
61
|
+
newDir.delete_if { |f| stgDir.include?(f) }
|
62
|
+
|
63
|
+
delFiles.delete_if { |f| stgFiles.include?(f) }
|
64
|
+
delDir.delete_if { |f| stgDir.include?(f) }
|
65
|
+
|
66
|
+
block.call(:workspace_overview, { modified: { files: modFiles, dirs: modDir }, new: { files: newFiles, dirs: newDir }, deleted: { files: delFiles, dirs: delDir }, staged: { files: stgFiles, dirs: stgDir } } )
|
67
|
+
|
68
|
+
end
|
69
|
+
|
29
70
|
def add(&block)
|
30
71
|
|
31
72
|
if block
|
32
|
-
|
33
|
-
loop do
|
34
73
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
modFiles.delete_if { |f| stgFiles.include?(f) }
|
41
|
-
modDir.delete_if { |f| stgDir.include?(f) }
|
42
|
-
|
43
|
-
newFiles.delete_if { |f| stgFiles.include?(f) }
|
44
|
-
newDir.delete_if { |f| stgDir.include?(f) }
|
45
|
-
|
46
|
-
delFiles.delete_if { |f| stgFiles.include?(f) }
|
47
|
-
delDir.delete_if { |f| stgDir.include?(f) }
|
48
|
-
|
49
|
-
res = block.call(:select_files_to_add, { modified: { files: modFiles, dirs: modDir }, new: { files: newFiles, dirs: newDir }, deleted: { files: delFiles, dirs: delDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self } )
|
50
|
-
|
51
|
-
doneTriggered = false
|
52
|
-
sel = res.clone
|
53
|
-
if sel.include?(:done)
|
54
|
-
sel.delete_if { |e| e == :done }
|
55
|
-
doneTriggered = true
|
56
|
-
end
|
74
|
+
stgDir, stgFiles = @ws.staged_files
|
75
|
+
modDir, modFiles = @ws.modified_files
|
76
|
+
newDir, newFiles = @ws.new_files
|
77
|
+
delDir, delFiles = @ws.deleted_files
|
57
78
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
79
|
+
modFiles.delete_if { |f| stgFiles.include?(f) }
|
80
|
+
modDir.delete_if { |f| stgDir.include?(f) }
|
81
|
+
|
82
|
+
newFiles.delete_if { |f| stgFiles.include?(f) }
|
83
|
+
newDir.delete_if { |f| stgDir.include?(f) }
|
84
|
+
|
85
|
+
delFiles.delete_if { |f| stgFiles.include?(f) }
|
86
|
+
delDir.delete_if { |f| stgDir.include?(f) }
|
87
|
+
|
88
|
+
res = block.call(:select_files_to_add, { modified: { files: modFiles, dirs: modDir }, new: { files: newFiles, dirs: newDir }, deleted: { files: delFiles, dirs: delDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self } )
|
68
89
|
|
69
|
-
|
90
|
+
sel = res.clone
|
70
91
|
|
92
|
+
if not_empty?(sel)
|
93
|
+
st, rres = @ws.add_to_staging(*sel)
|
94
|
+
if st
|
95
|
+
block.call(:files_added_successfully, { count: sel.length, output: rres })
|
96
|
+
else
|
97
|
+
block.call(:files_failed_to_be_added, { output: rres } )
|
98
|
+
end
|
99
|
+
else
|
100
|
+
block.call(:no_files_given)
|
71
101
|
end
|
72
102
|
|
103
|
+
|
73
104
|
end
|
74
105
|
|
75
106
|
end
|
@@ -78,40 +109,31 @@ module Release
|
|
78
109
|
|
79
110
|
if block
|
80
111
|
|
81
|
-
loop do
|
82
112
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
modFiles.delete_if { |f| stgFiles.include?(f) }
|
87
|
-
modDir.delete_if { |f| stgDir.include?(f) }
|
88
|
-
|
89
|
-
res = block.call(:select_files_to_diff, { modified: { files: modFiles, dirs: modDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self } )
|
90
|
-
|
91
|
-
doneTriggered = false
|
92
|
-
sel = res.clone
|
93
|
-
if sel.include?(:done)
|
94
|
-
sel.delete_if { |e| e == :done }
|
95
|
-
doneTriggered = true
|
96
|
-
end
|
113
|
+
stgDir, stgFiles = @ws.staged_files
|
114
|
+
modDir, modFiles = @ws.modified_files
|
97
115
|
|
98
|
-
|
99
|
-
|
100
|
-
st, rres = @ws.diff_file(s)
|
101
|
-
if st
|
102
|
-
block.call(:diff_file_result, { file: s, output: rres })
|
103
|
-
else
|
104
|
-
block.call(:diff_file_error, { file: s, output: rres } )
|
105
|
-
end
|
106
|
-
end
|
107
|
-
else
|
108
|
-
block.call(:no_files_given)
|
109
|
-
end
|
116
|
+
modFiles.delete_if { |f| stgFiles.include?(f) }
|
117
|
+
modDir.delete_if { |f| stgDir.include?(f) }
|
110
118
|
|
111
|
-
|
119
|
+
res = block.call(:select_files_to_diff, { modified: { files: modFiles, dirs: modDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self } )
|
112
120
|
|
121
|
+
sel = res.clone
|
122
|
+
|
123
|
+
if not_empty?(sel)
|
124
|
+
sel.each do |s|
|
125
|
+
st, rres = @ws.diff_file(s)
|
126
|
+
if st
|
127
|
+
block.call(:diff_file_result, { file: s, output: rres })
|
128
|
+
else
|
129
|
+
block.call(:diff_file_error, { file: s, output: rres } )
|
130
|
+
end
|
131
|
+
end
|
132
|
+
else
|
133
|
+
block.call(:no_files_given)
|
113
134
|
end
|
114
135
|
|
136
|
+
|
115
137
|
end
|
116
138
|
|
117
139
|
end
|
@@ -120,32 +142,21 @@ module Release
|
|
120
142
|
|
121
143
|
if block
|
122
144
|
|
123
|
-
|
145
|
+
newDir, newFiles = @ws.new_files
|
124
146
|
|
125
|
-
|
147
|
+
res = block.call(:select_files_to_ignore, { files: newFiles, dirs: newDir } )
|
126
148
|
|
127
|
-
|
149
|
+
sel = res.clone
|
128
150
|
|
129
|
-
|
130
|
-
|
131
|
-
if
|
132
|
-
|
133
|
-
doneTriggered = true
|
134
|
-
end
|
135
|
-
|
136
|
-
if not_empty?(sel)
|
137
|
-
st, rres = @ws.ignore(*sel)
|
138
|
-
if st
|
139
|
-
block.call(:files_ignored_successfully, { count: sel.length, output: rres })
|
140
|
-
else
|
141
|
-
block.call(:files_failed_to_be_ignored, { output: rres } )
|
142
|
-
end
|
151
|
+
if not_empty?(sel)
|
152
|
+
st, rres = @ws.ignore(*sel)
|
153
|
+
if st
|
154
|
+
block.call(:files_ignored_successfully, { count: sel.length, output: rres })
|
143
155
|
else
|
144
|
-
block.call(:
|
156
|
+
block.call(:files_failed_to_be_ignored, { output: rres } )
|
145
157
|
end
|
146
|
-
|
147
|
-
|
148
|
-
|
158
|
+
else
|
159
|
+
block.call(:no_files_given)
|
149
160
|
end
|
150
161
|
|
151
162
|
else
|
@@ -160,34 +171,24 @@ module Release
|
|
160
171
|
|
161
172
|
if block
|
162
173
|
|
163
|
-
|
164
|
-
|
165
|
-
stgDir, stgFiles = @ws.staged_files
|
174
|
+
stgDir, stgFiles = @ws.staged_files
|
166
175
|
|
167
|
-
|
176
|
+
res = block.call(:select_files_to_remove, { files: stgFiles, dirs: stgDir } )
|
168
177
|
|
169
|
-
|
170
|
-
sel = res.clone
|
171
|
-
if sel.include?(:done)
|
172
|
-
sel.delete_if { |e| e == :done }
|
173
|
-
doneTriggered = true
|
174
|
-
end
|
178
|
+
sel = res.clone
|
175
179
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
else
|
181
|
-
block.call(:files_removed_to_be_ignored, { output: rres } )
|
182
|
-
end
|
180
|
+
if not_empty?(sel)
|
181
|
+
st, rres = @ws.remove_from_staging(*sel)
|
182
|
+
if st
|
183
|
+
block.call(:files_removed_successfully, { count: sel.length, output: rres })
|
183
184
|
else
|
184
|
-
block.call(:
|
185
|
+
block.call(:files_removed_to_be_ignored, { output: rres } )
|
185
186
|
end
|
186
|
-
|
187
|
-
|
188
|
-
|
187
|
+
else
|
188
|
+
block.call(:no_files_given)
|
189
189
|
end
|
190
190
|
|
191
|
+
|
191
192
|
else
|
192
193
|
|
193
194
|
@ws.removed_from_staging(*files) if not_empty?(files)
|
@@ -197,66 +198,93 @@ module Release
|
|
197
198
|
end
|
198
199
|
|
199
200
|
def delete_file(*files, &block)
|
200
|
-
|
201
|
+
|
201
202
|
if block
|
202
|
-
|
203
|
-
loop do
|
204
203
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
sel = res.clone
|
219
|
-
if sel.include?(:done)
|
220
|
-
sel.delete_if { |e| e == :done }
|
221
|
-
doneTriggered = true
|
222
|
-
end
|
204
|
+
stgDir, stgFiles = @ws.staged_files
|
205
|
+
modDir, modFiles = @ws.modified_files
|
206
|
+
newDir, newFiles = @ws.new_files
|
207
|
+
|
208
|
+
modFiles.delete_if { |f| stgFiles.include?(f) }
|
209
|
+
modDir.delete_if { |f| stgDir.include?(f) }
|
210
|
+
|
211
|
+
newFiles.delete_if { |f| stgFiles.include?(f) }
|
212
|
+
newDir.delete_if { |f| stgDir.include?(f) }
|
213
|
+
|
214
|
+
res = block.call(:select_files_to_delete, { modified: { files: modFiles, dirs: modDir }, new: { files: newFiles, dirs: newDir }, staged: { files: stgFiles, dirs: stgDir } } )
|
215
|
+
|
216
|
+
sel = res.clone
|
223
217
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
end
|
218
|
+
if not_empty?(sel)
|
219
|
+
staged = []
|
220
|
+
nonTrack = []
|
221
|
+
sel.each do |s|
|
222
|
+
if s.is_a?(GitCli::Delta::NewFile)
|
223
|
+
confirm = block.call(:confirm_nontrack_delete, s.path)
|
224
|
+
if confirm
|
225
|
+
FileUtils.rm(s.path)
|
226
|
+
block.call(:nontrack_file_deleted, s.path)
|
227
|
+
end
|
228
|
+
elsif s.is_a?(GitCli::Delta::ModifiedFile)
|
229
|
+
# not staged
|
230
|
+
confirm = block.call(:confirm_vcs_delete, s.path)
|
231
|
+
puts "vcs confirm : #{confirm}"
|
232
|
+
if confirm
|
233
|
+
@ws.remove_from_vcs(s.path)
|
234
|
+
block.call(:vcs_file_deleted, s.path)
|
235
|
+
end
|
236
|
+
elsif s.is_a?(GitCli::Delta::StagedFile)
|
237
|
+
confirm = block.call(:confirm_staged_delete, s.path)
|
238
|
+
if confirm
|
239
|
+
@ws.remove_from_staging(s.path)
|
240
|
+
block.call(:staged_file_deleted, s.path)
|
248
241
|
end
|
249
242
|
end
|
250
|
-
|
251
|
-
else
|
252
|
-
block.call(:no_files_given)
|
253
243
|
end
|
254
244
|
|
255
|
-
|
245
|
+
else
|
246
|
+
block.call(:no_files_given)
|
247
|
+
end
|
248
|
+
|
256
249
|
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def commit_all(msg = nil, &block)
|
254
|
+
|
255
|
+
if block
|
256
|
+
|
257
|
+
stgDir, stgFiles = @ws.staged_files
|
258
|
+
modDir, modFiles = @ws.modified_files
|
259
|
+
delDir, delFiles = @ws.deleted_files
|
260
|
+
|
261
|
+
modFiles.delete_if { |f| stgFiles.include?(f) }
|
262
|
+
modDir.delete_if { |f| stgDir.include?(f) }
|
263
|
+
|
264
|
+
delFiles.delete_if { |f| stgFiles.include?(f) }
|
265
|
+
delDir.delete_if { |f| stgDir.include?(f) }
|
266
|
+
|
267
|
+
msg = block.call(:commit_message, { modified: { files: modFiles, dirs: modDir }, deleted: { files: delFiles, dirs: delDir }, staged: { files: stgFiles, dirs: stgDir } }) if is_empty?(msg)
|
268
|
+
raise VcsActionError, "Commit message is empty" if is_empty?(msg)
|
269
|
+
|
270
|
+
cp "Commit with user message : #{msg}"
|
271
|
+
st, res = @ws.commit_all(msg)
|
272
|
+
if st
|
273
|
+
block.call(:commit_successful, res) if block
|
274
|
+
else
|
275
|
+
block.call(:commit_failed, res) if block
|
257
276
|
end
|
277
|
+
[st, res]
|
278
|
+
|
279
|
+
else
|
280
|
+
|
281
|
+
msg = "Auto commit all ('-am' flag) by release-gem" if is_empty?(msg)
|
282
|
+
cp msg
|
283
|
+
# changed files only without new files
|
284
|
+
@ws.commit_all(msg)
|
258
285
|
|
259
286
|
end
|
287
|
+
|
260
288
|
end
|
261
289
|
|
262
290
|
def commit(msg = nil, &block)
|
@@ -265,32 +293,33 @@ module Release
|
|
265
293
|
if block
|
266
294
|
|
267
295
|
counter = 0
|
268
|
-
loop do
|
269
|
-
|
270
|
-
stgDir, stgFiles = @ws.staged_files
|
271
|
-
modDir, modFiles = @ws.modified_files
|
272
|
-
newDir, newFiles = @ws.new_files
|
273
|
-
delDir, delFiles = @ws.deleted_files
|
274
296
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
newDir.delete_if { |f| stgDir.include?(f) }
|
297
|
+
stgDir, stgFiles = @ws.staged_files
|
298
|
+
modDir, modFiles = @ws.modified_files
|
299
|
+
newDir, newFiles = @ws.new_files
|
300
|
+
delDir, delFiles = @ws.deleted_files
|
280
301
|
|
281
|
-
|
282
|
-
|
302
|
+
modFiles.delete_if { |f| stgFiles.include?(f) }
|
303
|
+
modDir.delete_if { |f| stgDir.include?(f) }
|
283
304
|
|
284
|
-
|
285
|
-
|
305
|
+
newFiles.delete_if { |f| stgFiles.include?(f) }
|
306
|
+
newDir.delete_if { |f| stgDir.include?(f) }
|
286
307
|
|
287
|
-
|
308
|
+
delFiles.delete_if { |f| stgFiles.include?(f) }
|
309
|
+
delDir.delete_if { |f| stgDir.include?(f) }
|
288
310
|
|
289
|
-
|
311
|
+
# block should call vcs for add, remove, ignore and other operations
|
312
|
+
res = block.call(:select_files_to_commit, { modified: { files: modFiles, dirs: modDir }, new: { files: newFiles, dirs: newDir }, deleted: { files: delFiles, dirs: delDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self, counter: counter } )
|
290
313
|
|
291
|
-
|
314
|
+
if not_empty?(res)
|
315
|
+
st, cres = add_to_staging(*res)
|
316
|
+
if st
|
317
|
+
@prmt.puts Gem.pastel.green(pmsg("\n Files added successfully"))
|
318
|
+
else
|
319
|
+
@prmt.puts Gem.pastel.red(pmsg("\n Files failed to be added. Message was : #{cres}"))
|
320
|
+
proceed = @prmt.yes?(" There are files failed to be added. Proceed with commit without those files?")
|
292
321
|
|
293
|
-
|
322
|
+
end
|
294
323
|
|
295
324
|
stgDir, stgFiles = @ws.staged_files
|
296
325
|
block.call(:staged_elements_of_commit, { files: stgFiles, dirs: stgDir })
|
@@ -307,18 +336,19 @@ module Release
|
|
307
336
|
end
|
308
337
|
[st, res]
|
309
338
|
|
339
|
+
else
|
340
|
+
@prmt.puts Gem.pastel.yellow("\n No files selected to be committed. Skipping commit.")
|
341
|
+
|
310
342
|
end
|
311
343
|
|
312
344
|
else
|
313
345
|
|
314
|
-
msg = "Auto commit all ('-am' flag) by
|
346
|
+
msg = "Auto commit all ('-am' flag) by release-gem" if is_empty?(msg)
|
315
347
|
cp msg
|
316
348
|
# changed files only without new files
|
317
349
|
@ws.commit_all(msg)
|
318
350
|
end
|
319
351
|
|
320
|
-
res
|
321
|
-
|
322
352
|
end
|
323
353
|
|
324
354
|
def tag(*args, &block)
|
@@ -376,9 +406,9 @@ module Release
|
|
376
406
|
end
|
377
407
|
end
|
378
408
|
|
379
|
-
raise VcsActionError, "Push repository remote cannot be empty" if is_empty?(remote)
|
409
|
+
#raise VcsActionError, "Push repository remote cannot be empty" if is_empty?(remote)
|
380
410
|
|
381
|
-
if remote != :skip
|
411
|
+
if not_empty?(remote) and remote != :skip
|
382
412
|
|
383
413
|
branch = @ws.current_branch if is_empty?(branch)
|
384
414
|
|