From e8013426a7c4c018e3c061e47a12a3f3c8d0ef50 Mon Sep 17 00:00:00 2001 From: Barrie Bremner Date: Wed, 30 Jan 2013 14:38:19 +0000 Subject: [PATCH] Avoid pulling a SHA if specified with -s revision=, just branches. --- lib/capistrano/deploy_tags.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/capistrano/deploy_tags.rb b/lib/capistrano/deploy_tags.rb index 2d251e7..6bef9d7 100644 --- a/lib/capistrano/deploy_tags.rb +++ b/lib/capistrano/deploy_tags.rb @@ -45,10 +45,22 @@ module Capistrano logger.log Capistrano::Logger::IMPORTANT, "Sorry, you have uncommitted changes. Please commit or stash them." end - logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy HEAD from branch '#{branch}' to '#{stage}'" + cdt.safe_run "git", "fetch" - cdt.safe_run "git", "checkout", branch - cdt.safe_run "git", "pull", "origin", branch if cdt.has_remote? + ref = fetch(:revision, branch) + + if exists?(:revision) + logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy '#{ref}' to '#{stage}'" + else + logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy HEAD from '#{ref}' to '#{stage}'" + end + + cdt.safe_run "git", "checkout", ref + + # It doesn't make sense to pull a SHA, only a branch. + if cdt.has_remote? && ! exists?(:revision) + cdt.safe_run "git", "pull", "origin", ref + end end desc 'add git tags for each successful deployment'