Permalink
Browse files

extract rollback changes to its own method

  • Loading branch information...
1 parent 6285849 commit d03da71eda0cfe3bc41c08e587c5137dc21e5ba1 @despo committed Mar 16, 2012
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/capistrano/recipes/deploy/strategy/copy.rb
@@ -61,10 +61,7 @@ def deploy!
create_local_cache
end
- # Check the return code of last system command and rollback if not 0
- unless $? == 0
- raise Capistrano::Error, "shell command failed with return code #{$?}"
- end
+ rollback_changes if last_command_failed?
build(copy_cache)
@@ -161,6 +158,14 @@ def create_local_cache
system(source.checkout(revision, copy_cache))
end
+ def rollback_changes
+ raise Capistrano::Error, "shell command failed with return code #{$?}"
+ end
+
+ def last_command_failed?
+ $? != 0
+ end
+
# Specify patterns to exclude from the copy. This is only valid
# when using a local cache.
def copy_exclude

0 comments on commit d03da71

Please sign in to comment.