release-gem 0.1.8 → 0.1.10

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: ed5f60168ae7d89802f6c0f5a18ff62bb055a66aef8ba9af2c87c6f10ecba99a
4
- data.tar.gz: dd3c409579297a14c397fb3e874a7da49856544b05a687727e4ae4f74f1be6e7
3
+ metadata.gz: ee50e97b208bc323892b6e5ed4af3812fd19cf1955241884d6700c94b03cdb24
4
+ data.tar.gz: 23b84aa1dea610e1e60bcced74fb15af3ae070e2f74f72b27427e9967e555ced
5
5
  SHA512:
6
- metadata.gz: 40e7a44d4694335fed765e3d96caffbbfd1d1b1a130f2ea9b8eec35268394b0d2eb4427c112b9e8fd369b05de9505f9c8d0765616bf4fc197733644b2bcd3db0
7
- data.tar.gz: cd3679b3878d822c8f4b1768f4ceafaa6fa7274030f928660ccdef78a438dd509f92d6234b93a3cfcdc8d537acce188e5e5b6517bfa69e27e7c94e453f8cb04d
6
+ metadata.gz: 2538c22c29d80482cdbb781e45b0570f3bd837075aea1fcb5833a242b494cf8e0aeb3383caaaf7e1d675486193b2406fb89dd316a424afc3e64c4bcb15cd84de
7
+ data.tar.gz: 61dd98175626747dbf74e800aa60842061029bf783695d4e28a0e21124d154fc2ae2e318afd19cebd8a4272695fcc2b6d8ca87ace8f3a9e0c50a61b17c904f0f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- release-gem (0.1.8)
4
+ release-gem (0.1.10)
5
5
  colorize
6
6
  git_cli
7
7
  gvcs
@@ -42,11 +42,10 @@ module Release
42
42
  instance_eval(&block) if block
43
43
  end
44
44
 
45
- def overview_changes(&block)
46
-
47
- res = :done
45
+ def add(&block)
46
+
48
47
  if block
49
-
48
+
50
49
  loop do
51
50
 
52
51
  stgDir, stgFiles = @ws.staged_files
@@ -63,83 +62,217 @@ module Release
63
62
  delFiles.delete_if { |f| stgFiles.include?(f) }
64
63
  delDir.delete_if { |f| stgDir.include?(f) }
65
64
 
66
- # block should call vcs for remove, ignore and diff
67
- res = block.call(:select_files_to_manage, { modified: { files: modFiles, dirs: modDir }, new: { files: newFiles, dirs: newDir }, deleted: { files: delFiles, dirs: delDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self } )
65
+ 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
66
 
69
- break if not res.is_a?(GitCli::Delta::VCSItem) and res == :done
67
+ doneTriggered = false
68
+ sel = res.clone
69
+ if sel.include?(:done)
70
+ sel.delete_if { |e| e == :done }
71
+ doneTriggered = true
72
+ end
73
+
74
+ if not_empty?(sel)
75
+ st, rres = @ws.add_to_staging(*sel)
76
+ if st
77
+ block.call(:files_added_successfully, { count: sel.length, output: rres })
78
+ else
79
+ block.call(:files_failed_to_be_added, { output: rres } )
80
+ end
81
+ else
82
+ block.call(:no_files_given)
83
+ end
84
+
85
+ break if doneTriggered
70
86
 
71
87
  end
72
88
 
73
89
  end
74
90
 
75
- res
76
-
77
91
  end
78
92
 
79
- #
80
- # Special operation since the gem build will only include files from
81
- # git ls-files
82
- #
83
- def commit_new_files(msg = nil, &block)
84
-
85
- res = :value
93
+ def diff(&block)
94
+
86
95
  if block
87
-
96
+
88
97
  loop do
89
98
 
90
99
  stgDir, stgFiles = @ws.staged_files
91
- newDir, newFiles = @ws.new_files
100
+ modDir, modFiles = @ws.modified_files
101
+
102
+ modFiles.delete_if { |f| stgFiles.include?(f) }
103
+ modDir.delete_if { |f| stgDir.include?(f) }
104
+
105
+ res = block.call(:select_files_to_diff, { modified: { files: modFiles, dirs: modDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self } )
92
106
 
93
- if is_empty?(newFiles)
94
- res = :skip
95
- break
107
+ doneTriggered = false
108
+ sel = res.clone
109
+ if sel.include?(:done)
110
+ sel.delete_if { |e| e == :done }
111
+ doneTriggered = true
96
112
  end
97
113
 
98
- newFiles.delete_if { |f| stgFiles.include?(f) }
99
- newDir.delete_if { |f| stgDir.include?(f) }
114
+ if not_empty?(sel)
115
+ sel.each do |s|
116
+ st, rres = @ws.diff_file(s)
117
+ if st
118
+ block.call(:diff_file_result, { file: s, output: rres })
119
+ else
120
+ block.call(:diff_file_error, { file: s, output: rres } )
121
+ end
122
+ end
123
+ else
124
+ block.call(:no_files_given)
125
+ end
100
126
 
101
- res = block.call(:select_files_to_commit, { new: { files: newFiles, dirs: newDir }, staged: { files: stgFiles, dirs: stgDir }, vcs: self } )
127
+ break if doneTriggered
102
128
 
103
- break if res == :skip or res == :done
129
+ end
130
+
131
+ end
132
+
133
+ end
134
+
135
+ def ignore(*files, &block)
136
+
137
+ if block
138
+
139
+ loop do
140
+
141
+ newDir, newFiles = @ws.new_files
142
+
143
+ res = block.call(:select_files_to_ignore, { files: newFiles, dirs: newDir } )
144
+
145
+ doneTriggered = false
146
+ sel = res.clone
147
+ if sel.include?(:done)
148
+ sel.delete_if { |e| e == :done }
149
+ doneTriggered = true
150
+ end
151
+
152
+ if not_empty?(sel)
153
+ st, rres = @ws.ignore(*sel)
154
+ if st
155
+ block.call(:files_ignored_successfully, { count: sel.length, output: rres })
156
+ else
157
+ block.call(:files_failed_to_be_ignored, { output: rres } )
158
+ end
159
+ else
160
+ block.call(:no_files_given)
161
+ end
162
+
163
+ break if doneTriggered
104
164
 
105
165
  end
106
166
 
107
- if res == :done
167
+ else
168
+
169
+ @ws.ignore(*files) if not_empty?(files)
170
+
171
+ end
172
+
173
+ end
174
+
175
+ def remove_from_staging(*files, &block)
176
+
177
+ if block
178
+
179
+ loop do
108
180
 
109
181
  stgDir, stgFiles = @ws.staged_files
110
- block.call(:staged_elements_of_commit, { files: stgFiles, dirs: stgDir })
111
182
 
112
- msg = block.call(:commit_message) if is_empty?(msg)
113
- raise VcsActionError, "Commit message is empty" if is_empty?(msg)
183
+ res = block.call(:select_files_to_remove, { files: stgFiles, dirs: stgDir } )
114
184
 
115
- cp "Commit with user message : #{msg}"
116
- st, res = @ws.commit(msg)
117
- if st
118
- block.call(:commit_successful, res) if block
185
+ doneTriggered = false
186
+ sel = res.clone
187
+ if sel.include?(:done)
188
+ sel.delete_if { |e| e == :done }
189
+ doneTriggered = true
190
+ end
191
+
192
+ if not_empty?(sel)
193
+ st, rres = @ws.remove_from_staging(*sel)
194
+ if st
195
+ block.call(:files_removed_successfully, { count: sel.length, output: rres })
196
+ else
197
+ block.call(:files_removed_to_be_ignored, { output: rres } )
198
+ end
119
199
  else
120
- block.call(:commit_failed, res) if block
200
+ block.call(:no_files_given)
121
201
  end
122
- [st, res]
202
+
203
+ break if doneTriggered
123
204
 
124
205
  end
125
206
 
207
+ else
126
208
 
127
- elsif not_empty?(msg)
209
+ @ws.removed_from_staging(*files) if not_empty?(files)
128
210
 
129
- newDir, newFiles = @ws.new_files
130
- add_to_staging(*newFiles)
211
+ end
212
+
213
+ end
214
+
215
+ def delete_file(*files, &block)
216
+
217
+ if block
218
+
219
+ loop do
220
+
221
+ stgDir, stgFiles = @ws.staged_files
222
+ modDir, modFiles = @ws.modified_files
223
+ newDir, newFiles = @ws.new_files
224
+
225
+ modFiles.delete_if { |f| stgFiles.include?(f) }
226
+ modDir.delete_if { |f| stgDir.include?(f) }
227
+
228
+ newFiles.delete_if { |f| stgFiles.include?(f) }
229
+ newDir.delete_if { |f| stgDir.include?(f) }
230
+
231
+ res = block.call(:select_files_to_delete, { modified: { files: modFiles, dirs: modDir }, new: { files: newFiles, dirs: newDir }, staged: { files: stgFiles, dirs: stgDir } } )
232
+
233
+ doneTriggered = false
234
+ sel = res.clone
235
+ if sel.include?(:done)
236
+ sel.delete_if { |e| e == :done }
237
+ doneTriggered = true
238
+ end
239
+
240
+ if not_empty?(sel)
241
+ staged = []
242
+ nonTrack = []
243
+ sel.each do |s|
244
+ if s.is_a?(GitCli::Delta::NewFile)
245
+ confirm = block.call(:confirm_nontrack_delete, s.path)
246
+ if confirm
247
+ FileUtils.rm(s.path)
248
+ block.call(:nontrack_file_deleted, s.path)
249
+ end
250
+ elsif s.is_a?(GitCli::Delta::ModifiedFile)
251
+ # not staged
252
+ confirm = block.call(:confirm_vcs_delete, s.path)
253
+ puts "vcs confirm : #{confirm}"
254
+ if confirm
255
+ @ws.remove_from_vcs(s.path)
256
+ block.call(:vcs_file_deleted, s.path)
257
+ end
258
+ elsif s.is_a?(GitCli::Delta::StagedFile)
259
+ confirm = block.call(:confirm_staged_delete, s.path)
260
+ if confirm
261
+ @ws.remove_from_staging(s.path)
262
+ block.call(:staged_file_deleted, s.path)
263
+ end
264
+ end
265
+ end
266
+
267
+ else
268
+ block.call(:no_files_given)
269
+ end
270
+
271
+ break if doneTriggered
131
272
 
132
- cp "Commit with user message : #{msg}"
133
- st, res = @ws.commit(msg)
134
- if st
135
- block.call(:commit_successful, res) if block
136
- else
137
- block.call(:commit_failed, res) if block
138
273
  end
139
- [st, res]
140
274
 
141
275
  end
142
-
143
276
  end
144
277
 
145
278
  def commit(msg = nil, &block)
@@ -220,16 +353,16 @@ module Release
220
353
 
221
354
  if is_empty?(msg)
222
355
  if block
223
- msg = block.call(:tag_message)
356
+ msg = block.call(:tag_message, { tag: tag })
224
357
  end
225
358
  end
226
359
 
227
360
  cp "tagged with name : #{tag} and message : #{msg}"
228
361
  st, res = @ws.create_tag(tag, msg)
229
362
  if st
230
- block.call(:tagging_success, res) if block
363
+ block.call(:tagging_success, { tag: tag, output: res }) if block
231
364
  else
232
- block.call(:tagging_failed, res) if block
365
+ block.call(:tagging_failed, { tag: tag, output: res }) if block
233
366
  end
234
367
 
235
368
  [st, res]
@@ -314,14 +447,6 @@ module Release
314
447
 
315
448
  end
316
449
 
317
- def ignore(*files)
318
- @ws.ignore(*files)
319
- end
320
-
321
- def remove_from_staging(*files)
322
- @ws.remove_from_staging(*files)
323
- end
324
-
325
450
 
326
451
  private
327
452
  def method_missing(mtd, *args, &block)
@@ -20,8 +20,49 @@ module Release
20
20
  instance_eval(&block) if block
21
21
  end
22
22
 
23
- def overview_changes(*args, &block)
24
- @inst.overview_changes do |ops, *args|
23
+ def manage_workspace(*args, &block)
24
+
25
+ loop do
26
+
27
+ ops = @prmt.select(pmsg("\n Please select a VCS workspace operation : ")) do |m|
28
+
29
+ m.choice "Add", :add
30
+ m.choice "Ignore", :ignore
31
+ m.choice "Diff", :diff
32
+ m.choice "Remove staged file", :remove_staged
33
+ m.choice "Delete file", :del
34
+ m.choice "Commit", :commit
35
+ m.choice "Done", :done
36
+ m.choice "Abort", :abort
37
+
38
+ end
39
+
40
+ case ops
41
+ when :abort
42
+ raise Release::Gem::Abort, "User aborted"
43
+ when :add
44
+ add
45
+ when :diff
46
+ diff
47
+ when :ignore
48
+ ignore
49
+ when :remove_staged
50
+ remove_staged
51
+ when :del
52
+ delete_file
53
+ when :commit
54
+ commit
55
+ break
56
+ when :done
57
+ break
58
+ end
59
+
60
+ end
61
+
62
+ end
63
+
64
+ def add(*input, &block)
65
+ @inst.add do |ops, *args|
25
66
  preset = false
26
67
  if block
27
68
  res = block.call(ops, *args)
@@ -36,71 +77,120 @@ module Release
36
77
 
37
78
  if preset
38
79
  case ops
39
- when :select_files_to_manage
40
- mfiles = args.first
80
+ when :select_files_to_add
41
81
 
42
- sel = @prmt.select pmsg("\n Following are files that could be managed : ") do |m|
82
+ mfiles = args.first
83
+ @prmt.puts pmsg("\n Files already added to staging : ")
84
+ mfiles[:staged].each do |k,v|
85
+ v.each do |vv|
86
+ @prmt.puts " * #{vv}"
87
+ end
88
+ end
43
89
 
44
- [:staged, :modified, :new, :deleted].each do |cat|
45
- mfiles[cat].each do |k,v|
46
- v.each do |vv|
47
- m.choice vv, vv
48
- end
90
+ @prmt.puts ""
91
+ res = []
92
+ [:modified, :new, :deleted].each do |cat|
93
+ mfiles[cat].each do |k,v|
94
+ v.each do |vv|
95
+ res << vv
49
96
  end
97
+ end
98
+ end
99
+
100
+ sel = @prmt.multi_select pmsg("\n Following are files that could be added to version control : ") do |m|
50
101
 
102
+ res.sort.each do |f|
103
+ m.choice f, f.path
51
104
  end
52
105
 
53
106
  m.choice "Done", :done
107
+ m.choice "Abort", :abort
108
+ end
54
109
 
110
+ if sel.include?(:abort)
111
+ raise Release::Gem::Abort, "User aborted"
112
+ else
113
+ sel
55
114
  end
56
115
 
57
- if sel.is_a?(GitCli::Delta::VCSItem)
116
+ when :files_added_successfully
117
+ v = args.first
118
+ @prmt.puts "\n #{v[:count]} file(s) added successfully.\n#{v[:output]}"
58
119
 
59
- selOps = @prmt.select pmsg("\n What do you want to do with file '#{sel.path}'?") do |m|
120
+ when :files_failed_to_be_added
121
+ v = args.first
122
+ @prmt.puts "\n File(s) failed to be added. Error was : \n#{v[:output]}"
60
123
 
61
- m.choice "Diff", :diff if not (sel.is_a?(GitCli::Delta::NewFile) or sel.is_a?(GitCli::Delta::NewDir))
62
- m.choice "Ignore", :ignore
63
- m.choice "Remove from staging", :remove_from_staging if sel.is_a?(GitCli::Delta::StagedFile)
64
- m.choice "Delete", :delete if (sel.is_a?(GitCli::Delta::NewFile) or sel.is_a?(GitCli::Delta::NewDir))
65
- m.choice "Done", :done
66
- end
124
+ end
67
125
 
68
- case selOps
69
- when :diff
70
- st, res = @inst.diff_file(sel.path)
71
- puts res
72
- STDIN.getc
73
- when :ignore
74
- confirm = @prmt.yes?(pmsg("\n Add file '#{sel.path}' to gitignore file?"))
75
- if confirm
76
- @inst.ignore(sel.path)
77
- end
78
- when :remove_from_staging
79
- confirm = @prmt.yes?(pmsg("\n Remove file '#{sel.path}' from staging?"))
80
- if confirm
81
- @inst.remove_from_staging(sel.path)
82
- end
83
- when :delete
84
- skip = @prmt.no?(pmsg("\n Delete the file '#{sel.path}' from file system? NOTE THIS CANNOT BE UNDONE! "))
85
- if not skip
86
- FileUtils.rm(sel.path)
126
+ end
127
+
128
+ end # block of add()
129
+ end
130
+
131
+ def diff(*input, &block)
132
+ @inst.diff do |ops, *args|
133
+ preset = false
134
+ if block
135
+ res = block.call(ops, *args)
136
+ if res.nil?
137
+ preset = true
138
+ else
139
+ res
140
+ end
141
+ else
142
+ preset = true
143
+ end
144
+
145
+ if preset
146
+ case ops
147
+ when :select_files_to_diff
148
+
149
+ mfiles = args.first
150
+ res = []
151
+ [:modified, :staged].each do |cat|
152
+ mfiles[cat].each do |k,v|
153
+ v.each do |vv|
154
+ res << vv
87
155
  end
88
- when :done
89
156
  end
157
+ end
158
+
159
+ sel = @prmt.multi_select pmsg("\n Select files for diff operation : ") do |m|
90
160
 
161
+ res.sort.each do |f|
162
+ m.choice f, f.path
163
+ end
164
+
165
+ m.choice "Done", :done
166
+ m.choice "Abort", :abort
91
167
  end
92
168
 
93
- sel
169
+ if sel.include?(:abort)
170
+ raise Release::Gem::Abort, "User aborted"
171
+ else
172
+ sel
173
+ end
174
+
175
+ when :diff_file_result
176
+ v = args.first
177
+ @prmt.puts "Diff result for file '#{v[:file]}'"
178
+ puts v[:output].light_blue
179
+ STDIN.gets
180
+
181
+ when :diff_file_error
182
+ v = args.first
183
+ @prmt.puts "\n Failed to diff file '#{v[:file]}'. Error was : \n#{v[:output]}"
94
184
 
95
185
  end
186
+
96
187
  end
97
188
 
98
- end
99
- end # overview_changes
189
+ end # block of add()
190
+ end
100
191
 
101
- def commit_new_files(*args, &block)
102
- res = @inst.commit_new_files do |ops, *args|
103
-
192
+ def ignore(*input, &block)
193
+ @inst.ignore do |ops, *args|
104
194
  preset = false
105
195
  if block
106
196
  res = block.call(ops, *args)
@@ -114,87 +204,172 @@ module Release
114
204
  end
115
205
 
116
206
  if preset
117
-
118
207
  case ops
119
- when :select_files_to_commit
208
+ when :select_files_to_ignore
209
+
120
210
  mfiles = args.first
121
- @prmt.puts pmsg("\n Files already added to staging : ")
122
- mfiles[:staged].each do |k,v|
123
- v.each do |vv|
124
- @prmt.puts " * #{vv}"
211
+ sel = @prmt.multi_select pmsg("\n Following are files that could be ignored : ") do |m|
212
+
213
+ mfiles[:files].sort.each do |v|
214
+ m.choice v, v.path
125
215
  end
216
+
217
+
218
+ m.choice "Done", :done
219
+ m.choice "Abort", :abort
126
220
  end
127
221
 
128
- @prmt.puts ""
222
+ if sel.include?(:abort)
223
+ raise Release::Gem::Abort, "User aborted"
224
+ else
225
+ sel
226
+ end
129
227
 
130
- sel = @prmt.multi_select pmsg("\n Following are new files that could be added to version control.\n Don't worry if you found not all changed files are here. There will be another commit session after the build : ") do |m|
228
+ when :files_ignored_successfully
229
+ v = args.first
230
+ @prmt.puts "\n #{v[:count]} file(s) ignored successfully.\n#{v[:output]}"
131
231
 
132
- mfiles[:new].each do |k,v|
133
- v.each do |vv|
134
- m.choice vv, vv.path
135
- end
232
+ when :files_failed_to_be_ignored
233
+ v = args.first
234
+ @prmt.puts "\n File(s) failed to be ignored. Error was : \n#{v[:output]}"
235
+
236
+ end
237
+
238
+ end
239
+
240
+ end # block of add()
241
+ end
242
+
243
+ def remove_staged(*input, &block)
244
+ @inst.remove_from_staging do |ops, *args|
245
+ preset = false
246
+ if block
247
+ res = block.call(ops, *args)
248
+ if res.nil?
249
+ preset = true
250
+ else
251
+ res
252
+ end
253
+ else
254
+ preset = true
255
+ end
256
+
257
+ if preset
258
+ case ops
259
+ when :select_files_to_remove
260
+
261
+ mfiles = args.first
262
+
263
+ sel = @prmt.multi_select pmsg("\n Following are files that could be removed from staging : ") do |m|
264
+
265
+ mfiles[:files].sort.each do |v|
266
+ m.choice v, v.path
136
267
  end
137
268
 
138
- m.choice "Skip", :skip #if mfiles[:counter] == 0
269
+
139
270
  m.choice "Done", :done
140
271
  m.choice "Abort", :abort
141
272
  end
142
273
 
143
274
  if sel.include?(:abort)
144
275
  raise Release::Gem::Abort, "User aborted"
145
- elsif sel.include?(:skip)
146
- :skip
147
276
  else
148
- res = :done if sel.include?(:done)
149
- s = sel.clone
150
- s.delete_if { |e| e == :done }
151
- if not_empty?(s)
152
- st, cres = add_to_staging(*s) if not_empty?(s)
153
- if st
154
- @prmt.puts pmsg("\n Files added successfully", :green)
155
- else
156
- @prmt.puts pmsg("\n Files failed to be added. Message was : #{cres}", :red)
277
+ sel
278
+ end
279
+
280
+ when :files_removed_successfully
281
+ v = args.first
282
+ @prmt.puts "\n #{v[:count]} file(s) removed successfully.\n#{v[:output]}"
283
+
284
+ when :files_removed_to_be_ignored
285
+ v = args.first
286
+ @prmt.puts "\n File(s) failed to be removed. Error was : \n#{v[:output]}"
287
+
288
+ end
289
+
290
+ end
291
+
292
+ end # block
293
+ end
294
+
295
+ def delete_file(*args, &block)
296
+ res = @inst.delete_file do |ops, *args|
297
+
298
+ preset = false
299
+ if block
300
+ res = block.call(ops, *args)
301
+ if res.nil?
302
+ preset = true
303
+ else
304
+ res
305
+ end
306
+ else
307
+ preset = true
308
+ end
309
+
310
+ if preset
311
+
312
+ case ops
313
+ when :select_files_to_delete
314
+ mfiles = args.first
315
+
316
+ files = []
317
+ [:new, :staged, :modified].each do |cat|
318
+ mfiles[cat].each do |k,v|
319
+ v.each do |vv|
320
+ files << vv
321
+ #m.choice vv, vv
157
322
  end
158
323
  end
159
324
 
160
- res
161
-
162
325
  end
163
326
 
164
- when :commit_message
165
- msg = ""
166
- loop do
167
- msg = @prmt.ask(pmsg("\n Commit message : "), required: true)
168
- confirm = @prmt.yes?(pmsg(" Commit message : #{msg}\n Proceed? No to provide a new commit message "))
169
- if confirm
170
- break
327
+
328
+ sel = @prmt.multi_select pmsg("\n Following are files that could be deleted : ") do |m|
329
+ files.sort do |f|
330
+ m.choice f, f
171
331
  end
332
+ m.choice "Done", :done
333
+ m.choice "Abort", :abort
172
334
  end
173
335
 
174
- msg
175
-
176
- when :staged_elements_of_commit
177
336
 
178
- elements = args.first
179
- @prmt.puts pmsg("\n Following new files/directories shall be committed in this session : ")
180
- elements.each do |k,v|
181
- v.each do |vv|
182
- @prmt.puts " * #{vv}"
183
- end
337
+ if sel.include?(:abort)
338
+ raise Release::Gem::Abort, "User aborted"
339
+ else
340
+ sel
184
341
  end
185
342
 
186
- when :commit_successful
187
- @prmt.puts pmsg("\n Changes committed",:green)
188
- @prmt.puts args.first
343
+ when :confirm_nontrack_delete
344
+ v = args.first
345
+ @prmt.yes?(pmsg("\n Delete non-tracked file '#{v}'? "))
189
346
 
190
- when :commit_failed
191
- @prmt.puts pmsg("\n Changes failed to be committed. Error was : #{args.first}")
347
+ when :nontrack_file_deleted
348
+ v = args.first
349
+ @prmt.puts pmsg("\n Non tracked file '#{v}' deleted ")
350
+
351
+ when :confirm_vcs_delete
352
+ v = args.first
353
+ not @prmt.no?(pmsg("\n Delete version-controlled file '#{v}'?\n After delete the file will no longer keeping track of changes. "))
354
+
355
+ when :vcs_file_deleted
356
+ v = args.first
357
+ @prmt.puts pmsg("\n Version-controlled file '#{v}' deleted ")
358
+
359
+ when :confirm_staged_delete
360
+ v = args.first
361
+ @prmt.yes?(pmsg("\n Delete staged file '#{v}'?\n After delete the file shall be removed from staging. The file will still exist physically "))
362
+
363
+ when :staged_file_deleted
364
+ v = args.first
365
+ @prmt.puts pmsg("\n Staged file '#{v}' deleted ")
192
366
 
193
367
  end
194
368
  end
195
- end # commit_new_files block
369
+ end # delete_file block
370
+
371
+ end # delete_file
196
372
 
197
- end # commit_new_files
198
373
 
199
374
 
200
375
  def commit(*args, &block)
@@ -226,15 +401,22 @@ module Release
226
401
 
227
402
  @prmt.puts ""
228
403
 
229
- sel = @prmt.multi_select pmsg("\n Following are files that could be added to version control : ") do |m|
230
-
231
- [:modified, :new, :deleted].each do |cat|
232
- mfiles[cat].each do |k,v|
233
- v.each do |vv|
234
- m.choice vv, vv.path
235
- end
404
+ files = []
405
+ [:modified, :new, :deleted].each do |cat|
406
+ mfiles[cat].each do |k,v|
407
+ v.each do |vv|
408
+ files << vv
409
+ #m.choice vv, vv.path
236
410
  end
411
+ end
412
+
413
+ end
237
414
 
415
+
416
+ sel = @prmt.multi_select pmsg("\n Following are files that could be added to version control : ") do |m|
417
+
418
+ files.sort.each do |f|
419
+ m.choice f, f.path
238
420
  end
239
421
 
240
422
  m.choice "Skip", :skip #if mfiles[:counter] == 0
@@ -318,14 +500,17 @@ module Release
318
500
 
319
501
  case ops
320
502
  when :tag_message
321
- @prmt.ask(pmsg("\n Please provide message for the tag : "), value: "Auto tagging by gem-release gem during releasing version #{@selVer}", required: true)
503
+ v = args.first
504
+ @prmt.ask(pmsg("\n Please provide message for the tag : "), value: "Auto tagging by gem-release gem during releasing version #{v[:tag]}", required: true)
322
505
 
323
506
  when :tagging_success
324
- @prmt.puts pmsg("\n Tagging of source code is successful.", :green)
325
- @prmt.puts args.first
507
+ v = args.first
508
+ @prmt.puts pmsg("\n Tagging of source code with tag '#{v[:tag]}' is successful.", :green)
509
+ @prmt.puts v[:output]
326
510
 
327
511
  when :tagging_failed
328
- @prmt.puts pmsg("\n Tagging of source code failed. Error was : #{args.first}", :red)
512
+ v = args.first
513
+ @prmt.puts pmsg("\n Tagging of source code with tag '#{v[:tag]}' failed. Error was : #{v[:output]}", :red)
329
514
 
330
515
  when :no_tagging_required
331
516
  @prmt.puts pmsg("\n No tagging required. Source head is the tagged item ", :green)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Release
4
4
  module Gem
5
- VERSION = "0.1.8"
5
+ VERSION = "0.1.10"
6
6
  end
7
7
  end
@@ -10,15 +10,11 @@ Release::Gem.engine(:gem, root: Dir.getwd) do
10
10
  # step 1 : run test
11
11
  run_test(:rspec)
12
12
 
13
- # to allow user to get a view on what's changed
14
- # and allow user to ignore or remove file from staging
15
- vcs_cli_overview_changes
16
-
17
13
  # Reason to put it here is because gem build shall
18
14
  # only consider files already inside git system via
19
15
  # git ls-files command. Anything new that is not yet
20
16
  # check in will not be packup by the gem build process
21
- vcs_cli_commit
17
+ vcs_cli_manage_workspace
22
18
 
23
19
  # step 2 : check dependency
24
20
  gem_cli_release_dependencies
@@ -34,17 +30,13 @@ Release::Gem.engine(:gem, root: Dir.getwd) do
34
30
  gem_cli_install(version: ver)
35
31
  end
36
32
 
37
- puts "version : #{ver}"
38
-
39
- @selVer = value(:selected_version)
40
-
41
33
  vcs_add_to_staging_if_commit_before("Gemfile.lock")
42
34
  vcs_add_to_staging(value(:version_file_path))
43
35
 
44
- vcs_commit("Commit after gem version #{@selVer} built")
36
+ vcs_commit("Commit after gem version #{ver} built")
45
37
 
46
38
  # step 7 : tag the source code
47
- vcs_cli_tag( tag: @selVer )
39
+ vcs_cli_tag( tag: ver )
48
40
 
49
41
  # step 8 : Push the source code
50
42
  vcs_cli_push
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: release-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris