From dcca41a841a9f488249445efecf8a1c51ba6a25c Mon Sep 17 00:00:00 2001 From: Dinis Date: Thu, 16 Jan 2020 18:32:54 +0000 Subject: [PATCH] Call system instead of execute and run_locally. --- lib/capistrano/tasks/deploytags.rake | 68 +++++++++++++--------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/lib/capistrano/tasks/deploytags.rake b/lib/capistrano/tasks/deploytags.rake index f447007..de1d35d 100644 --- a/lib/capistrano/tasks/deploytags.rake +++ b/lib/capistrano/tasks/deploytags.rake @@ -1,51 +1,47 @@ namespace :deploy do desc 'prepare git tree so we can tag on successful deployment' before :deploy, :prepare_tree do - run_locally do - if ENV['NO_DEPLOYTAGS'] || fetch(:no_deploytags, false) - info "[deploytags] Skipping deploytags" - else - branch = fetch(:branch, false) - stage = fetch(:stage, false) + if ENV['NO_DEPLOYTAGS'] || fetch(:no_deploytags, false) + info "[deploytags] Skipping deploytags" + else + branch = fetch(:branch, false) + stage = fetch(:stage, false) - unless branch && stage - error 'capistrano-deploytags requires that :branch and :stage be defined' - raise 'define :branch and :stage' - end - - execute :git, "fetch #{fetch(:git_remote, 'origin')}" - - diff_output = capture :git, "diff #{branch} --shortstat" - - unless diff_output.empty? - error "Whoa there, partner. Dirty trees can't deploy. Git yerself clean first" - raise 'Dirty git tree' - end - - execute :git, "checkout #{branch}" - info "Pulling from #{branch}" - execute :git, "pull #{fetch(:git_remote, 'origin')} #{branch}" + unless branch && stage + error 'capistrano-deploytags requires that :branch and :stage be defined' + raise 'define :branch and :stage' end + + system :git, "fetch #{fetch(:git_remote, 'origin')}" + + diff_output = capture :git, "diff #{branch} --shortstat" + + unless diff_output.empty? + error "Whoa there, partner. Dirty trees can't deploy. Git yerself clean first" + raise 'Dirty git tree' + end + + system :git, "checkout #{branch}" + info "Pulling from #{branch}" + system :git, "pull #{fetch(:git_remote, 'origin')} #{branch}" end end desc 'add git tags for each successful deployment' after :cleanup, :tagdeploy do - run_locally do - if ENV['NO_DEPLOYTAGS'] || fetch(:no_deploytags, false) - info "[deploytags] Skipping deploytags" - else - tag_name = ENV['CUSTOM_DEPLOYTAG'] || fetch(:custom_deploytag) || CapistranoDeploytags::Helper.git_tag_for(fetch(:stage)) - latest_revision = fetch(:current_revision) - commit_message = CapistranoDeploytags::Helper.commit_message(latest_revision, fetch(:stage)) + if ENV['NO_DEPLOYTAGS'] || fetch(:no_deploytags, false) + info "[deploytags] Skipping deploytags" + else + tag_name = ENV['CUSTOM_DEPLOYTAG'] || fetch(:custom_deploytag) || CapistranoDeploytags::Helper.git_tag_for(fetch(:stage)) + latest_revision = fetch(:current_revision) + commit_message = CapistranoDeploytags::Helper.commit_message(latest_revision, fetch(:stage)) - unless fetch(:sshkit_backend) == SSHKit::Backend::Printer # unless --dry-run flag present - execute :git, "tag -a #{tag_name} -m \"#{commit_message}\" #{latest_revision}" - execute :git, "push #{fetch(:git_remote, 'origin')} #{tag_name}" - end - - info "[cap-deploy-tagger] Tagged #{latest_revision} with #{tag_name}" + unless fetch(:sshkit_backend) == SSHKit::Backend::Printer # unless --dry-run flag present + system :git, "tag -a #{tag_name} -m \"#{commit_message}\" #{latest_revision}" + system :git, "push #{fetch(:git_remote, 'origin')} #{tag_name}" end + + info "[cap-deploy-tagger] Tagged #{latest_revision} with #{tag_name}" end end end