Check state of local tree with git status, rather than a diff, since there's no guarantee we're at the right point on the branch at this stage.

This commit is contained in:
Barrie Bremner
2013-01-30 14:08:59 +00:00
parent 2bd711ab9c
commit e84f6a359d
+8 -8
View File
@@ -1,8 +1,9 @@
module Capistrano
module DeployTags
def pending_git_changes?
# Do we have any changes vs HEAD on deployment branch?
!(`git fetch && git diff #{branch} --shortstat`.strip.empty?)
def uncommitted_git_changes?
# Is the working directory clean?
!( `git status --porcelain`.strip.empty? )
end
def git_tag_for(stage)
@@ -40,13 +41,12 @@ module Capistrano
task :prepare_tree, :except => { :no_release => true } do
cdt.validate_git_vars
logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy HEAD from branch '#{branch}' to '#{stage}'"
if cdt.pending_git_changes?
logger.log Capistrano::Logger::IMPORTANT, "Whoa there, partner. Dirty trees can't deploy. Git yerself clean first."
raise 'Dirty git tree'
if cdt.uncommitted_git_changes?
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", "checkout", branch
cdt.safe_run "git", "pull", "origin", branch if cdt.has_remote?
end