From bff204320f44b56675bd994f9e1c5248c7c5c4d3 Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Wed, 16 May 2018 17:30:47 +0200 Subject: [PATCH] Fixed tar archive containing subfolder if from-path was specified in configuration --- src/Task/BuiltIn/Deploy/Tar/PrepareTask.php | 7 ++++++- tests/Command/BuiltIn/DeployCommandWithReleasesTest.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php b/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php index 9db8486..b38a18d 100644 --- a/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php +++ b/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php @@ -43,7 +43,12 @@ class PrepareTask extends AbstractTask $excludes = $this->getExcludes(); $tarPath = $this->runtime->getEnvOption('tar_create_path', 'tar'); $flags = $this->runtime->getEnvOption('tar_create', 'cfzp'); - $from = $this->runtime->getEnvOption('from', './'); + $from = './'; + + if ($fromPath = $this->runtime->getEnvOption('from', false)) { + $from = '-C '.$fromPath.' '.$from; + } + $cmdTar = sprintf('%s %s %s %s %s', $tarPath, $flags, $tarLocal, $excludes, $from); /** @var Process $process */ diff --git a/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php b/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php index 366e38d..92e47ce 100644 --- a/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php +++ b/tests/Command/BuiltIn/DeployCommandWithReleasesTest.php @@ -139,7 +139,7 @@ class DeployCommandWithReleasesTest extends TestCase 2 => 'git pull', 3 => 'composer install --optimize-autoloader', 4 => 'composer dump-autoload --optimize', - 5 => 'tar cfzp /tmp/mageXYZ --exclude=".git" --exclude="./var/cache/*" --exclude="./var/log/*" --exclude="./web/app_dev.php" ./dist', + 5 => 'tar cfzp /tmp/mageXYZ --exclude=".git" --exclude="./var/cache/*" --exclude="./var/log/*" --exclude="./web/app_dev.php" -C ./dist ./', 6 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "mkdir -p /var/www/test/releases/1234567890"', 7 => 'scp -P 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/mageXYZ tester@testhost:/var/www/test/releases/1234567890/mageXYZ', 8 => 'ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no tester@testhost "cd /var/www/test/releases/1234567890 && tar xfzop mageXYZ"',