From ff5f87ff801abb1bdcf3cd9f2f09ce660e57b40f Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 29 Mar 2015 21:56:51 -0700 Subject: [PATCH] run non-destructive shell commands during dry runs --- server/harp_blog.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server/harp_blog.rb b/server/harp_blog.rb index ec77c61..4e8d3c0 100644 --- a/server/harp_blog.rb +++ b/server/harp_blog.rb @@ -352,8 +352,8 @@ class HarpBlog s.gsub('"', '\\"') end - def run(cmd) - if @dry_run + def run(cmd, safety = :destructive) + if safety == :destructive && @dry_run puts ">>> cd '#{@path}' && #{cmd}" else `cd '#{@path}' && #{cmd} 2>&1` @@ -361,11 +361,7 @@ class HarpBlog end def git_sha - if output = run('git log -n1 | head -n1 | cut -d" " -f2') - output.strip - else - 'fake-sha' - end + run('git log -n1 | head -n1 | cut -d" " -f2', :nondestructive).strip end def git_commit(action, title, *files)