From a66478b3abc0463e14c288332cdb3d27ca7bd289 Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Wed, 29 Oct 2014 23:16:52 +0400 Subject: [PATCH] exclude from file added. rebased by upstream --- .../BuiltIn/Deployment/Strategy/RsyncTask.php | 16 ++++++++++++++++ .../BuiltIn/Deployment/Strategy/TarGzTask.php | 19 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index b7ee1b5..f01d243 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -52,6 +52,7 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware $this->checkOverrideRelease(); $excludes = $this->getExcludes(); + $excludesListFilePath = $this->getExcludesListFile(); // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); @@ -95,6 +96,7 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware . $strategyFlags . ' ' . '--rsh="ssh ' . $this->getConfig()->getHostIdentityFileOption() . '-p' . $this->getConfig()->getHostPort() . '" ' . $this->excludes($excludes) . ' ' + . $this->excludesListFile($excludesListFilePath) . ' ' . $this->getConfig()->deployment('from') . ' ' . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory; $result = $this->runCommandLocal($command); @@ -117,4 +119,18 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware $excludesRsync = trim($excludesRsync); return $excludesRsync; } + + /** + * Generates the Exclude from file for rsync + * @param string $excludesFilePath + * @return string + */ + protected function excludesListFile($excludesFilePath) + { + $excludesListFileRsync = ''; + if(!empty($excludesFilePath)) { + $excludesListFileRsync = ' --exclude-from=' . $excludesFilePath; + } + return $excludesListFileRsync; + } } diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index bea390f..f5c0031 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -46,6 +46,7 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware $this->checkOverrideRelease(); $excludes = $this->getExcludes(); + $excludesListFilePath = $this->getExcludesListFile(); // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); @@ -66,6 +67,8 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware $excludeCmd .= ' --exclude=' . $excludeFile; } + $excludeFromFileCmd = $this->excludesListFile($excludesListFilePath); + // Strategy Flags $strategyFlags = $this->getConfig()->deployment('strategy_flags', $this->getConfig()->general('strategy_flags', array())); if (isset($strategyFlags['targz']) && isset($strategyFlags['targz']['create'])) { @@ -74,7 +77,7 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware $strategyFlags = ''; } - $command = 'tar cfzh' . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .'; + $command = 'tar cfzh' . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . $excludeFromFileCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .'; $result = $this->runCommandLocal($command); // Strategy Flags @@ -112,4 +115,18 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware return $result; } + + /** + * Generates the Exclude from file for TarGz + * @param string $excludesFilePath + * @return string + */ + protected function excludesListFile($excludesFilePath) + { + $excludesListFileRsync = ''; + if(!empty($excludesFilePath)) { + $excludesListFileRsync = ' --exclude-from=' . $excludesFilePath; + } + return $excludesListFileRsync; + } }