lib/shuttle/strategy.rb in shuttle-deploy-0.2.0.beta2 vs lib/shuttle/strategy.rb in shuttle-deploy-0.2.0.beta3

- old
+ new

@@ -23,9 +23,32 @@ checkout_code link_release cleanup_releases end + def rollback + if last_version == 0 + error "There are no releases to rollback to" + end + + release = available_releases.select { |v| v == last_version-1 }.first + + if release + if ssh.run("unlink #{current_path}").failure? + ssh.run("rm -rf #{current_path}") + end + + if ssh.run("ln -s #{deploy_path}/releases/#{release} #{current_path}").failure? + error "Unable to create symlink to current path" + end + + ssh.run("echo #{version} > #{version_path}") + log "Rolled back to release v#{release}" + else + error "There are no older releases" + end + end + def update_code if config.app.svn return update_code_svn end \ No newline at end of file