hu 1.3.23 → 1.4.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
  SHA1:
3
- metadata.gz: 32585e3867e76c97598713a8177c01bf4a213949
4
- data.tar.gz: 3ab2ba38631a63a91532a17ab34d770a5fdbce8d
3
+ metadata.gz: 154e304d7bbeb118a8dc0ff897ccb0dc6215bd1b
4
+ data.tar.gz: 8c8378d3a43cf0c3489ad3506093640732aa9482
5
5
  SHA512:
6
- metadata.gz: e6eaf746681ae17552108281ba3a9a6f54e1ed112b0f2b8dd97d18a240bcb6fd9f962fbeaa2e6b76d1b541a2cc309fdb976d0681f079e8829cf88d7501f1c557
7
- data.tar.gz: b5254ee661dba218a165c461d9cc664e8f6847e4d3ae60981005017558eedaf5eb1067e4871706d4d016c8feb9efc56a7fd8e4e76fcef9ffefc010f737076426
6
+ metadata.gz: 65d0637b1b9bde463b4c52e04239655fecc1a68e73fcfea8d41fdcd40807bb31b8c758a6de9e046b843842064b3716ffe51bc70dc17e500f880d2f2e9d726e60
7
+ data.tar.gz: 5283ad18537bd354ee872138279bd723919e3aeda0420f1371e3d8c3f9e5e498d71b8d087ce4a28f94b12b497283c5fae12fcc49e729b0b81a2b8f30800993a7
@@ -6,12 +6,12 @@ Lint/HandleExceptions:
6
6
 
7
7
  # Offense count: 6
8
8
  Metrics/CyclomaticComplexity:
9
- Max: 45
9
+ Max: 450
10
10
 
11
11
  # Offense count: 15
12
12
  # Configuration parameters: CountComments.
13
13
  Metrics/MethodLength:
14
- Max: 254
14
+ Max: 500
15
15
 
16
16
  # Offense count: 4
17
17
  Metrics/PerceivedComplexity:
@@ -137,7 +137,7 @@ module Hu
137
137
  end
138
138
 
139
139
  stag_app_name = app['name']
140
- busy "fetching heroku app #{prod_app_id}", :dots
140
+ busy 'synchronizing', :dots
141
141
  prod_app_name = h.app.info(prod_app_id)['name']
142
142
  unbusy
143
143
 
@@ -189,7 +189,7 @@ module Hu
189
189
  release_branch_exists = branch_exists?("release/#{release_tag}")
190
190
 
191
191
  if release_branch_exists
192
- puts "\nThis release will be " + release_tag.color(:red).bright
192
+ puts "\nThis release will be " + release_tag.color(:green).bright
193
193
  unless highest_version == 'v0.0.0'
194
194
  env = {
195
195
  'PREVIOUS_TAG' => highest_version,
@@ -207,29 +207,29 @@ module Hu
207
207
  puts
208
208
 
209
209
  unless git_revisions[:release] == git_revisions[stag_app_name] || !release_branch_exists
210
- puts 'Phase 1/3: The local release branch ' + "release/#{release_tag}".bright + ' was created.'
211
- puts ' Nothing else has happened so far. Push this branch to'
212
- puts ' ' + stag_app_name.to_s.bright + ' to begin the deploy procedure.'
210
+ puts ' Phase 1/3 '.inverse + ' The local release branch ' + "release/#{release_tag}".bright + ' was created.'
211
+ puts ' Nothing else has happened so far. Push this branch to'
212
+ puts ' ' + stag_app_name.to_s.bright + ' to begin the deploy procedure.'
213
213
  puts
214
214
  Hu::Tm.t(:phase1, cmd: 'deploy')
215
215
  end
216
216
 
217
217
  if release_branch_exists && git_revisions[:release] == git_revisions[stag_app_name]
218
- puts 'Phase 2/3: Your local ' + "release/#{release_tag}".bright + ' (formerly ' + 'develop'.bright + ') is live at ' + stag_app_name.to_s.bright + '.'
219
- puts ' Please test here: ' + (app['web_url']).to_s.bright
220
- puts ' If everything looks good, you may proceed and finish the release.'
221
- puts ' If there are problems: Quit, delete the release branch and start fixing.'
218
+ puts ' Phase 2/3 '.inverse + ' Your local ' + "release/#{release_tag}".bright + ' (formerly ' + 'develop'.bright + ') is live at ' + stag_app_name.to_s.bright + '.'
219
+ puts ' Please test here: ' + (app['web_url']).to_s.bright
220
+ puts ' If everything looks good, you may proceed and finish the release.'
221
+ puts ' If there are problems: Quit, delete the release branch and start fixing.'
222
222
  puts
223
223
  Hu::Tm.t(:phase2, cmd: 'deploy')
224
224
  elsif git_revisions[prod_app_name] != git_revisions[stag_app_name] && !release_branch_exists && git_revisions[:release] != git_revisions[stag_app_name]
225
- puts 'Phase 3/3: HEADS UP! This is the last chance to detect problems.'
226
- puts ' The final version of ' + "release/#{release_tag}".bright + ' is now staged.'
225
+ puts ' Phase 3/3 '.inverse + ' HEADS UP! This is the last chance to detect problems.'
226
+ puts ' The final version of ' + "release/#{release_tag}".bright + ' is now staged.'
227
227
  puts
228
- puts ' Test here: ' + (app['web_url']).to_s.bright
228
+ puts ' Test here: ' + (app['web_url']).to_s.bright
229
229
  sleep 1
230
230
  puts
231
- puts ' This is the exact version that will be promoted to production.'
232
- puts " From here you are on your own. Good luck #{`whoami`.chomp}!"
231
+ puts ' This is the exact version that will be promoted to production.'
232
+ puts " From here you are on your own. Good luck #{`whoami`.chomp}!"
233
233
  puts
234
234
  Hu::Tm.t(:phase3, cmd: 'deploy')
235
235
  end
@@ -262,8 +262,6 @@ module Hu
262
262
  end
263
263
  end
264
264
 
265
- puts
266
-
267
265
  case choice
268
266
  when :DEPLOY
269
267
  Hu::Tm.t(:promote_begin, cmd: 'deploy')
@@ -328,19 +326,23 @@ module Hu
328
326
  release_tag, branch_already_exists = prompt_for_release_tag(major_bump, major_bump)
329
327
  Hu::Tm.t(:switch_release_type, bump: 'major', cmd: 'deploy')
330
328
  end
329
+ when :refresh
330
+ puts
331
331
  end
332
332
  end
333
333
  end
334
334
 
335
335
  def show_pipeline_status(pipeline_name, stag_app_name, prod_app_name, release_tag, clear = true)
336
336
  table = TTY::Table.new header: %w(location commit tag app_last_modified app_last_modified_by dynos# state)
337
- busy 'loading', :huroku
337
+ busy 'synchronizing', :huroku
338
338
  ts = []
339
339
  workers = []
340
340
  tpl_row = ['?', '', '', '', '', '', '']
341
341
  revs = ThreadSafe::Hash.new
342
342
  app_config = ThreadSafe::Hash.new
343
343
 
344
+ revs[:develop] = `git rev-parse develop`[0..5]
345
+
344
346
  [[0, stag_app_name], [1, prod_app_name]].each do |idx, app_name|
345
347
  workers << Thread.new do
346
348
  # config vars
@@ -375,6 +377,8 @@ module Hu
375
377
 
376
378
  revs[app_name] = table_row[1] = slug_info['commit'][0..5]
377
379
 
380
+ table_row[1] = table_row[1].color(table_row[1] == revs[:develop] ? :green : :red)
381
+
378
382
  table_row[2] = `git tag --points-at #{slug_info['commit']} 2>/dev/null`
379
383
  table_row[2] = '' unless $?.success?
380
384
 
@@ -406,19 +410,21 @@ module Hu
406
410
  row[0] = 'master'
407
411
  revs[:master] = row[1] = `git rev-parse master`[0..5]
408
412
  row[2] = `git tag --points-at master`
413
+ row[1] = row[1].color(row[1] == revs[:develop] ? :green : :red)
409
414
  rows.unshift row
410
415
 
411
416
  if branch_exists? "release/#{release_tag}"
412
417
  row = tpl_row.dup
413
418
  row[0] = "release/#{release_tag}"
414
419
  revs["release/#{release_tag}"] = revs[:release] = row[1] = `git rev-parse release/#{release_tag}`[0..5]
420
+ row[1] = row[1].color(row[1] == revs[:release] ? :green : :red)
415
421
  row[2] = `git tag --points-at release/#{release_tag} 2>/dev/null`
416
422
  rows.unshift row
417
423
  end
418
424
 
419
425
  row = tpl_row.dup
420
426
  row[0] = 'develop'
421
- revs[:develop] = row[1] = `git rev-parse develop`[0..5]
427
+ row[1] = revs[:develop].color(:green)
422
428
  row[2] = `git tag --points-at develop`
423
429
  rows.unshift row
424
430
 
@@ -448,7 +454,7 @@ module Hu
448
454
  end
449
455
 
450
456
  def heroku_app_by_git(git_url)
451
- busy('fetching heroku apps', :dots)
457
+ busy('synchronizing', :dots)
452
458
  r = h.app.list.select { |e| e['git_url'] == git_url }
453
459
  unbusy
454
460
  raise "FATAL: Found multiple heroku apps with git_url=#{git_url}" if r.length > 1
@@ -456,7 +462,7 @@ module Hu
456
462
  end
457
463
 
458
464
  def heroku_pipeline_details(app)
459
- busy('fetching heroku pipelines', :dots)
465
+ busy('synchronizing', :dots)
460
466
  couplings = h.pipeline_coupling.list
461
467
  unbusy
462
468
  r = couplings.select { |e| e['app']['id'] == app['id'] }
@@ -689,38 +695,53 @@ module Hu
689
695
  EOS
690
696
  end
691
697
 
692
- def prompt_for_release_tag(propose_version = 'v0.0.1', try_version = nil, keep_existing = false)
698
+ def prompt_for_release_tag(_propose_version = 'v0.0.1', try_version = nil, keep_existing = false)
693
699
  prompt = TTY::Prompt.new
694
700
  loop do
695
701
  if try_version
696
702
  release_tag = try_version
697
- try_version = nil
698
- else
699
- show_existing_git_tags
700
- release_tag = prompt.ask('Please enter a tag for this release', default: propose_version)
701
- begin
702
- unless release_tag[0] == 'v'
703
- raise ArgumentError, 'Version string must start with the letter v'
704
- end
705
- raise ArgumentError, 'too short' if release_tag.length < 5
706
- Versionomy.parse(release_tag)
707
- rescue => e
708
- puts "Error: Tag does not look like a semantic version (#{e})".color(:red)
709
- next
710
- end
703
+ # try_version = nil
711
704
  end
705
+ # else
706
+ # show_existing_git_tags
707
+ # release_tag = prompt.ask('Please enter a tag for this release', default: propose_version)
708
+ # begin
709
+ # unless release_tag[0] == 'v'
710
+ # raise ArgumentError, 'Version string must start with the letter v'
711
+ # end
712
+ # raise ArgumentError, 'too short' if release_tag.length < 5
713
+ # Versionomy.parse(release_tag)
714
+ # rescue => e
715
+ # puts "Error: Tag does not look like a semantic version (#{e})".color(:red)
716
+ # next
717
+ # end
718
+ # end
712
719
 
713
720
  branches = `git for-each-ref refs/heads/ --format='%(refname:short)'`.lines.map(&:chomp)
714
721
  existing_branch = branches.find { |b| b.start_with? 'release/' }
715
722
  branch_already_exists = !existing_branch.nil?
716
723
  release_tag = existing_branch[8..-1] if keep_existing && branch_already_exists
717
724
 
718
- if branch_already_exists && !keep_existing
719
- choice = prompt.expand("The branch '" + "release/#{release_tag}".color(:red) + "' already exists. What shall we do?",
720
- default: 0) do |q|
721
- q.choice key: 'k', name: 'Keep, continue with the existing branch', value: :keep
722
- q.choice key: 'D', name: "Delete branch release/#{release_tag} and retry", value: :delete
723
- q.choice key: 'q', name: 'Quit', value: :quit
725
+ revs = {}
726
+ revs[:develop] = `git rev-parse develop`[0..5]
727
+ revs[:release] = `git rev-parse release/#{release_tag}`[0..5] if branch_already_exists
728
+
729
+ if branch_already_exists && revs[:develop] != revs[:release]
730
+ puts
731
+
732
+ puts 'Oops!'.bright
733
+ puts
734
+ puts 'Your release-branch ' + "release/#{release_tag}".bright + ' is out of sync with ' + 'develop'.bright + '.'
735
+ puts
736
+ puts 'develop is at ' + revs[:develop].bright + ", release/#{release_tag} is at " + revs[:release].bright + '.'
737
+ puts
738
+ puts 'This usually means the release branch is old and does not'
739
+ puts 'not reflect what you actually want to deploy right now.'
740
+ puts
741
+ choice = prompt.select('What shall we do?') do |menu|
742
+ menu.enum '.'
743
+ menu.choice "Delete branch 'release/#{release_tag}' and create new release branch from 'develop'", :delete
744
+ menu.choice 'Quit - do nothing, let me inspect the situation', :quit
724
745
  end
725
746
 
726
747
  case choice
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Hu
3
- VERSION = '1.3.23'
3
+ VERSION = '1.4.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.23
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - moe