From 7c883d2436b1b18a29b53044f6aa8345c9e42a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sun, 16 Mar 2014 18:21:42 -0300 Subject: [PATCH] Tweaks for issue #45 - Issue #45 - Adds "ssh_needs_tty" which appends "-t" to the ssh. - Issue #45 - Rsync is incremental if there are previous releases. --- Mage/Task/AbstractTask.php | 4 ++-- Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Mage/Task/AbstractTask.php b/Mage/Task/AbstractTask.php index e1ea934..d6afcec 100644 --- a/Mage/Task/AbstractTask.php +++ b/Mage/Task/AbstractTask.php @@ -188,9 +188,9 @@ abstract class AbstractTask } else { $releasesDirectory = ''; } - + // if general.yml includes "ssy_needs_tty: true", then add "-t" to the ssh command - $needs_tty = ($this->getConfig()->general('ssh_needs_tty',false) ? "-t" : ""); + $needs_tty = ($this->getConfig()->general('ssh_needs_tty',false) ? '-t' : ''); $localCommand = 'ssh ' . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' ' . '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index 345b404..ead532c 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -75,17 +75,18 @@ class RsyncTask extends AbstractTask implements IsReleaseAware if ($this->getConfig()->release('enabled', false) == true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); + $currentRelease = false; $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId(); - $resultFetch = $this->runCommandRemote('ls -ld current | cut -d"/" -f2', $releaseToOverride); - - if ( $resultFetch ) { + $resultFetch = $this->runCommandRemote('ls -ld current | cut -d"/" -f2', $currentRelease); + + if ($resultFetch && $currentRelease) { // If deployment configuration is rsync, include a flag to simply sync the deltas between the prior release // rsync: { copy: yes } - $rsync_copy = $this->getConfig()->deployment("rsync"); + $rsync_copy = $this->getConfig()->deployment('rsync'); if ( $rsync_copy && is_array($rsync_copy) && $rsync_copy['copy'] ) { - $this->runCommandRemote('cp -R ' . $releasesDirectory . '/' . $releaseToOverride . ' ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); + $this->runCommandRemote('cp -R ' . $releasesDirectory . '/' . $currentRelease . ' ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); } else { $this->runCommandRemote('mkdir -p ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); }