Permalink
Browse files

rename rollback_changes to raise_command_failed

and refactored cleanup to new rollback_changes method
  • Loading branch information...
1 parent 9c83fce commit 8a12de625c5c23cee3d75e6a82c650ab7212e684 @despo committed Mar 16, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/capistrano/recipes/deploy/strategy/copy.rb
View
13 lib/capistrano/recipes/deploy/strategy/copy.rb
@@ -61,7 +61,7 @@ def deploy!
create_local_cache
end
- rollback_changes if last_command_failed?
+ raise_command_failed if last_command_failed?
build(copy_cache)
copy_cache_to_server
@@ -79,8 +79,7 @@ def deploy!
distribute!
ensure
- FileUtils.rm filename rescue nil
- FileUtils.rm_rf destination rescue nil
+ rollback_changes
end
def build(directory)
@@ -89,7 +88,7 @@ def build(directory)
Dir.chdir(directory) do
self.system(configuration[:build_script])
- rollback_changes if last_command_failed?
+ raise_command_failed if last_command_failed?
end
end
@@ -123,7 +122,7 @@ def create_local_cache
system(source.checkout(revision, copy_cache))
end
- def rollback_changes
+ def raise_command_failed
raise Capistrano::Error, "shell command failed with return code #{$?}"
end
@@ -181,6 +180,10 @@ def compress_repository
Dir.chdir(copy_dir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) }
end
+ def rollback_changes
+ FileUtils.rm filename rescue nil
+ FileUtils.rm_rf destination rescue nil
+ end
# Specify patterns to exclude from the copy. This is only valid
# when using a local cache.
def copy_exclude

0 comments on commit 8a12de6

Please sign in to comment.