diff --git a/lib/capistrano/deploy_tags.rb b/lib/capistrano/deploy_tags.rb index cad3a23..89204eb 100644 --- a/lib/capistrano/deploy_tags.rb +++ b/lib/capistrano/deploy_tags.rb @@ -38,6 +38,8 @@ module Capistrano desc 'prepare git tree so we can tag on successful deployment' namespace :git do task :prepare_tree, :except => { :no_release => true } do + next if fetch(:no_deploytags, false) + cdt.validate_git_vars logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy HEAD from branch '#{branch}' to '#{stage}'" @@ -53,6 +55,8 @@ module Capistrano desc 'add git tags for each successful deployment' task :tagdeploy, :except => { :no_release => true } do + next if fetch(:no_deploytags, false) + cdt.validate_git_vars current_sha = `git rev-parse #{branch} HEAD`.strip[0..8] @@ -60,7 +64,6 @@ module Capistrano tag_user = (ENV['USER'] || ENV['USERNAME']).strip cdt.safe_run "git", "tag", "-a", cdt.git_tag_for(stage), "-m", "#{tag_user} deployed #{current_sha} to #{stage}" - cdt.safe_run "git", "push", "--tags" if cdt.has_remote? end end diff --git a/spec/capistrano_deploy_tags_spec.rb b/spec/capistrano_deploy_tags_spec.rb index d3c64f7..3bac851 100644 --- a/spec/capistrano_deploy_tags_spec.rb +++ b/spec/capistrano_deploy_tags_spec.rb @@ -46,6 +46,16 @@ describe Capistrano::DeployTags do end end end + + it "does not run when :no_deploytags is defined by (i.e. by the stage)" do + with_clean_repo do + configuration.set(:branch, 'master') + configuration.set(:stage, 'test') + configuration.set(:no_deploytags, true) + configuration.cdt.should_not_receive(:validate_git_vars) + expect { configuration.find_and_execute_task('git:prepare_tree') }.to_not raise_error + end + end end context "tagdeploy" do @@ -69,5 +79,15 @@ describe Capistrano::DeployTags do tags.first.should =~ /^test-\d{4}\.\d{2}\.\d{2}/ end end + + it "does not run when :no_deploytags is defined by (i.e. by the stage)" do + with_clean_repo do + configuration.set(:branch, 'master') + configuration.set(:stage, 'test') + configuration.set(:no_deploytags, true) + configuration.cdt.should_not_receive(:validate_git_vars) + expect { configuration.find_and_execute_task('git:prepare_tree') }.to_not raise_error + end + end end end