Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Commit

Permalink
improve rollback task
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Jul 11, 2013
1 parent 8068947 commit 4f04493
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/git_deploy.rb
Expand Up @@ -71,12 +71,16 @@ def rerun

desc "rollback", "Rolls back the checkout to before the last push"
def rollback
run "cd #{deploy_to} && git reset --hard ORIG_HEAD"
if run_test("test -x #{deploy_to}/deploy/rollback")
run "cd #{deploy_to} && deploy/rollback 2>&1 | tee -a log/deploy.log"
else
invoke :restart
end
run <<-BASH, :echo => false
bash -e -c '
cd '#{deploy_to}'
declare -a revs=( $(git rev-parse HEAD HEAD@{1}) )
git reset --hard ${revs[1]}
callback=after_push
[ -x deploy/rollback ] && callback=rollback
deploy/$callback ${revs[@]} 2>&1 | tee -a log/deploy.log
'
BASH
end

desc "log", "Shows the last part of the deploy log on the server"
Expand Down

0 comments on commit 4f04493

Please sign in to comment.