lib/hu/deploy.rb in hu-2.0.13 vs lib/hu/deploy.rb in hu-2.0.14
- old
+ new
@@ -101,10 +101,12 @@
shutdown
return_to_home_branch
print "\e[0m\e[?25h"
end
+ dp :discover
+
begin
@git = Rugged::Repository.discover('.')
rescue Rugged::RepositoryError => e
print TTY::Cursor.clear_line + TTY::Cursor.show
puts
@@ -124,20 +126,24 @@
puts " Please run 'git config branch.master.remote origin'"
puts
exit 1
end
+ dp 'detect git-flow'
+
if @git.config['gitflow.branch.master'].nil?
print TTY::Cursor.clear_line + TTY::Cursor.show
puts
puts "ERROR: This repository doesn't seem to be git-flow enabled.".color(:red)
puts
puts " Please run 'git flow init -d'"
puts
exit 1
end
+ dp 'detect git-flow prefix'
+
unless @git.config['gitflow.prefix.versiontag'].nil? ||
@git.config['gitflow.prefix.versiontag'].empty?
print TTY::Cursor.clear_line + TTY::Cursor.show
puts
puts 'ERROR: git-flow version prefix configured.'.color(:red)
@@ -147,15 +153,19 @@
puts " git config --add gitflow.prefix.versiontag ''".bright
puts
exit 1
end
+ dp 'detect git-remote'
+
push_url = heroku_git_remote
@@home_branch = current_branch_name
+ dp 'update working copy'
wc_update = Thread.new { update_working_copy }
+ dp 'fetch heroku apps'
app = heroku_app_by_git(push_url)
if app.nil?
print TTY::Cursor.clear_line + TTY::Cursor.show
puts
@@ -165,12 +175,14 @@
puts " Please run 'git remote rm heroku'. Then run 'hu deploy' again to select a new remote."
puts
exit 1
end
+ dp 'fetch pipelines'
pipeline_name, stag_app_id, prod_app_id = heroku_pipeline_details(app)
+ dp 'validate app id'
if app['id'] != stag_app_id
print TTY::Cursor.clear_line + TTY::Cursor.show
puts
puts "ERROR: The git remote 'heroku' points to app '#{app['name']}'".color(:red)
puts " which is not in stage 'staging'".color(:red) +
@@ -184,12 +196,15 @@
exit 1
end
stag_app_name = app['name']
busy 'synchronizing', :dots
+
+ dp 'fetch prod app'
prod_app_name = h.app.info(prod_app_id)['name']
+ dp 'wait for update'
wc_update.join
unless develop_can_be_merged_into_master?
unbusy
puts
@@ -197,31 +212,38 @@
puts ' Aborting early to prevent a merge conflict.'.color(:red)
puts
exit 1
end
+ dp 'fetch version'
highest_version = find_highest_version_tag
begin
highest_versionomy = Versionomy.parse(highest_version)
rescue
highest_versionomy = Versionomy.parse('v0.0.0')
end
+ dp 'fetch tags'
all_tags = Set.new(@git.references.to_a('refs/tags/*').collect { |o| o.name[10..-1] })
tiny_bump = highest_versionomy.dup
minor_bump = highest_versionomy.dup
major_bump = highest_versionomy.dup
+ dp 'calc version A'
loop do
tiny_bump = tiny_bump.bump(:tiny)
break unless all_tags.include? tiny_bump.to_s
end
+
+ dp 'calc version B'
loop do
minor_bump = minor_bump.bump(:minor)
break unless all_tags.include? minor_bump.to_s
end
+
+ dp 'calc version C'
loop do
major_bump = major_bump.bump(:major)
break unless all_tags.include? tiny_bump.to_s
end
tiny_bump = tiny_bump.to_s
@@ -236,10 +258,11 @@
prompt = TTY::Prompt.new
clearscreen = true
loop do
+ dp 'render'
git_revisions = show_pipeline_status(pipeline_name, stag_app_name, prod_app_name, release_tag, clearscreen)
if git_revisions[:develop] == `git rev-parse master`[0..5] && git_revisions[:develop] == git_revisions[prod_app_name] &&
git_revisions[prod_app_name] != git_revisions[stag_app_name]
puts
@@ -1415,11 +1438,13 @@
end
def dp(label, *args)
return unless ENV['DEBUG']
puts "--- DEBUG #{label} ---"
- ap(*args)
- puts "--- ^#{label}^ ---"
+ if args.length > 0
+ ap(*args)
+ puts "--- ^#{label}^ ---"
+ end
end
end # /Class Deploy
end # /Class Cli
end # /Module Hu