lib/hu/deploy.rb in hu-1.2.2 vs lib/hu/deploy.rb in hu-1.2.3

- old
+ new

@@ -15,10 +15,11 @@ module Hu class Cli < Optix::Cli class Deploy < Optix::Cli @@shutting_down = false + @@spinner = nil text "Interactive deployment." desc "Interactive deployment" if Hu::API_TOKEN.nil? text "" @@ -30,18 +31,29 @@ exit 1 end end def deploy(cmd, opts, argv) - trap('INT') { shutdown; safe_abort } + trap('INT') { shutdown; safe_abort; exit 1 } at_exit { if 130 == $!.status shutdown puts safe_abort + exit $!.status end } + + unless File.exists? '.git' + puts + puts "You need to be inside the working directory of the app that you wish to deploy.".color(:red) + puts + safe_abort + print TTY::Cursor.prev_line + exit 1 + end + push_url = get_heroku_git_remote wc_update = Thread.new { update_working_copy } app = heroku_app_by_git(push_url) @@ -149,12 +161,11 @@ push_command = "git push #{push_url} release/#{release_tag}:master -f" `#{push_command}` puts anykey when :abort_ask - delete_branch("release/#{release_tag}") - puts + puts if delete_branch("release/#{release_tag}") exit 0 when :retag if delete_branch("release/#{release_tag}") release_tag, branch_already_exists = prompt_for_release_tag(likely_next_version) end @@ -447,10 +458,11 @@ branches = `git for-each-ref refs/heads/ --format='%(refname:short)'`.lines.map(&:chomp) existing_branch = branches.find {|e| e.start_with? 'release/'} branch_already_exists = !existing_branch.nil? release_tag = existing_branch[8..-1] if keep_existing && branch_already_exists + if branch_already_exists && !keep_existing choice = prompt.expand("The branch '"+"release/#{release_tag}".color(:red)+"' already exists. What shall we do?", {default: 0}) do |q| q.choice key: 'k', name: 'Keep, continue with the existing branch', value: :keep q.choice key: 'D', name: "Delete branch release/#{release_tag} and retry", value: :delete @@ -473,10 +485,11 @@ develop_tag=`git tag --points-at develop 2>/dev/null`.lines.find { |e| e[0] == 'v' }&.chomp if develop_tag release_tag = develop_tag else start_release(release_tag) + puts end end return release_tag, branch_already_exists end @@ -564,11 +577,11 @@ ap *args puts "--- ^#{label}^ ---" end def safe_abort - @@spinner.stop + @@spinner&.stop printf "\e[0m\e[?25l" printf '(ヘ・_・)ヘ┳━┳' sleep 0.5 printf "\e[12D(ヘ・_・)-┳━┳" sleep 0.1 @@ -581,10 +594,9 @@ printf "\e[30;1m\e[16D(╯°□°)╯ ┻━┻" sleep 0.05 printf "\e[17D " printf "\e[?25h" puts - exit 1 end end end end