From 91f246b579730b09c4f8299b1f307706ec973517 Mon Sep 17 00:00:00 2001 From: Benjamin Kluge Date: Wed, 15 Feb 2017 12:31:17 +0100 Subject: [PATCH] [FEATURE] allow exclude definition global --- src/Task/BuiltIn/Deploy/RsyncTask.php | 2 +- src/Task/BuiltIn/Deploy/Tar/PrepareTask.php | 2 +- .../BuiltIn/DeployCommandMiscTasksTest.php | 22 +++++++++++++++++-- tests/Resources/global-exclude.yml | 17 ++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 tests/Resources/global-exclude.yml diff --git a/src/Task/BuiltIn/Deploy/RsyncTask.php b/src/Task/BuiltIn/Deploy/RsyncTask.php index 1dce74e..57e1d0d 100644 --- a/src/Task/BuiltIn/Deploy/RsyncTask.php +++ b/src/Task/BuiltIn/Deploy/RsyncTask.php @@ -54,7 +54,7 @@ class RsyncTask extends AbstractTask protected function getExcludes() { - $excludes = $this->runtime->getEnvOption('exclude', []); + $excludes = $this->runtime->getMergedOption('exclude', []); $excludes = array_merge(['.git'], array_filter($excludes)); foreach ($excludes as &$exclude) { diff --git a/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php b/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php index e694f8f..d982000 100644 --- a/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php +++ b/src/Task/BuiltIn/Deploy/Tar/PrepareTask.php @@ -51,7 +51,7 @@ class PrepareTask extends AbstractTask protected function getExcludes() { - $excludes = $this->runtime->getEnvOption('exclude', []); + $excludes = $this->runtime->getMergedOption('exclude', []); $excludes = array_merge(['.git'], array_filter($excludes)); foreach ($excludes as &$exclude) { diff --git a/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php b/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php index ae13f8b..d0a9d39 100644 --- a/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php +++ b/tests/Command/BuiltIn/DeployCommandMiscTasksTest.php @@ -50,9 +50,27 @@ class DeployCommandMiscTasksTest extends TestCase $this->assertEquals(0, $tester->getStatusCode()); } - public function testComposerFlags() + public function composerFlagsDataProvider() { + return [ + 'default' => [ + 'yml' => __DIR__ . '/../../Resources/composer.yml' + ], + 'global exclude' => [ + 'yml' => __DIR__ . '/../../Resources/global-exclude.yml' + ], + ]; + } + + /** + * testComposerFlags + * + * @dataProvider composerFlagsDataProvider + * @param string $yml + * @return void + */ + public function testComposerFlags($yml) { - $application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer.yml'); + $application = new MageApplicationMockup($yml); /** @var AbstractCommand $command */ $command = $application->find('deploy'); diff --git a/tests/Resources/global-exclude.yml b/tests/Resources/global-exclude.yml new file mode 100644 index 0000000..cfa5ddf --- /dev/null +++ b/tests/Resources/global-exclude.yml @@ -0,0 +1,17 @@ +magephp: + log_dir: /tmp + composer: + path: /usr/bin/composer.phar + exclude: + - ./var/cache/* + - ./var/log/* + - ./web/app_dev.php + environments: + test: + user: tester + host_path: /var/www/test + hosts: + - testhost + pre-deploy: + - composer/install: { flags: '--prefer-source' } + - composer/dump-autoload: { flags: '--no-scripts' }