Allow Exclude to be defined globally.

This commit is contained in:
Andrés Montañez 2017-04-14 16:29:22 -03:00
parent ef72936c52
commit 0fe106610a
5 changed files with 50 additions and 2 deletions

View file

@ -2,6 +2,7 @@ CHANGELOG for 3.X
=================
* 3.2.0 (2017-04-xx)
* Allow to define excludes in the global scope.
* Improve code quality, remove duplications on Symfony Tasks.
* Improve code quality, remove duplications on Composer Tasks.
* [PR#364] Allow to define custom timeout to Composer:Install

View file

@ -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) {

View file

@ -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) {

View file

@ -80,6 +80,36 @@ class DeployCommandMiscTasksTest extends TestCase
$this->assertEquals(0, $tester->getStatusCode());
}
public function testGlobalExcludeFlags()
{
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/global-exclude.yml');
/** @var AbstractCommand $command */
$command = $application->find('deploy');
$this->assertTrue($command instanceof DeployCommand);
$tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test']);
$ranCommands = $application->getRuntime()->getRanCommands();
$testCase = array(
0 => '/usr/bin/composer.phar install --prefer-source',
1 => '/usr/bin/composer.phar dump-autoload --no-scripts',
2 => 'rsync -e "ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" -avz --exclude=.git --exclude=./var/cache/* --exclude=./var/log/* --exclude=./web/app_dev.php ./ tester@testhost:/var/www/test',
);
// Check total of Executed Commands
$this->assertEquals(count($testCase), count($ranCommands));
// Check Generated Commands
foreach ($testCase as $index => $command) {
$this->assertEquals($command, $ranCommands[$index]);
}
$this->assertEquals(0, $tester->getStatusCode());
}
public function testComposerEnvFlags()
{
$application = new MageApplicationMockup(__DIR__ . '/../../Resources/composer-env.yml');

View file

@ -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' }