run non-destructive shell commands during dry runs

This commit is contained in:
Sami Samhuri 2015-03-29 21:56:51 -07:00
parent 09b1224646
commit ff5f87ff80

View file

@ -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)