From 79d86af7be42995f32c59657696022e27a81e0dc Mon Sep 17 00:00:00 2001 From: Mark Connell Date: Thu, 4 Sep 2014 11:25:57 +0100 Subject: [PATCH] Prevent bad commits deploying. In the event of a fatal error occuring when trying to add content to git for commit, you end up pushing a blank commit to the git respository. This is a change which halts the push to a git repository so you don't accidentally take down your website. --- lib/middleman-deploy/strategies/git/base.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/middleman-deploy/strategies/git/base.rb b/lib/middleman-deploy/strategies/git/base.rb index 2073969..f1151c1 100644 --- a/lib/middleman-deploy/strategies/git/base.rb +++ b/lib/middleman-deploy/strategies/git/base.rb @@ -37,9 +37,14 @@ module Middleman def commit_branch(options = '') message = self.commit_message ? self.commit_message : add_signature_to_commit_message('Automated commit') - `git add -A` - `git commit --allow-empty -am "#{message}"` - `git push #{options} origin #{self.branch}` + run_or_fail("git add -A") + run_or_fail("git commit --allow-empty -am \"#{message}\"") + run_or_fail("git push #{options} origin #{self.branch}") + end + + private + def run_or_fail(command) + system(command) || raise("ERROR running: #{command}") end end end