From c24762935675609f5c5adadc544170f72abaebc6 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Fri, 13 Dec 2013 11:53:56 +0000 Subject: [PATCH] correctly handle failing git fetch If the repository doesn't have an upstream branch configured, git fetch will output an error; handle this separately to prevent it interfering with the git diff call which checks to see if we have any pending changes. --- lib/capistrano/deploy_tags.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/capistrano/deploy_tags.rb b/lib/capistrano/deploy_tags.rb index c395689..1a49fa2 100644 --- a/lib/capistrano/deploy_tags.rb +++ b/lib/capistrano/deploy_tags.rb @@ -2,7 +2,12 @@ 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?) + out = `git fetch 2>&1` + if $?.success? + ! (`git diff #{branch} --shortstat`.strip.empty?) + else + raise CommandError.new("git fetch failed:\n" + out) + end end def git_tag_for(stage)