1
0
Fork 0

Update ClassMapGenerator to work better with symlinks, fixes #7252, closes #7251

pull/7088/merge
Petr /Peggy/ Sládek 2018-04-11 12:33:27 +02:00 committed by Jordi Boggiano
parent 72476b62d4
commit 8d06832077
2 changed files with 18 additions and 0 deletions

View File

@ -94,6 +94,10 @@ class ClassMapGenerator
if ($blacklist && preg_match($blacklist, strtr(realpath($filePath), '\\', '/'))) { if ($blacklist && preg_match($blacklist, strtr(realpath($filePath), '\\', '/'))) {
continue; continue;
} }
// check non-realpath of file for directories symlink in project dir
if ($blacklist && preg_match($blacklist, strtr($filePath, '\\', '/'))) {
continue;
}
$classes = self::findClasses($filePath); $classes = self::findClasses($filePath);

View File

@ -23,6 +23,7 @@ use Composer\Repository\InstalledRepositoryInterface;
use Composer\Installer\InstallationManager; use Composer\Installer\InstallationManager;
use Composer\Config; use Composer\Config;
use Composer\EventDispatcher\EventDispatcher; use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\Platform;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit_Framework_MockObject_MockObject as MockObject;
class AutoloadGeneratorTest extends TestCase class AutoloadGeneratorTest extends TestCase
@ -1292,6 +1293,7 @@ EOF;
), ),
'classmap' => array('composersrc/'), 'classmap' => array('composersrc/'),
'exclude-from-classmap' => array( 'exclude-from-classmap' => array(
'/composersrc/foo/bar/',
'/composersrc/excludedTests/', '/composersrc/excludedTests/',
'/composersrc/ClassToExclude.php', '/composersrc/ClassToExclude.php',
'/composersrc/*/excluded/excsubpath', '/composersrc/*/excluded/excsubpath',
@ -1326,6 +1328,18 @@ EOF;
file_put_contents($this->workingDir.'/composersrc/long/excluded/excsubpath/foo.php', '<?php class ClassExcludeMapFoo2 {}'); file_put_contents($this->workingDir.'/composersrc/long/excluded/excsubpath/foo.php', '<?php class ClassExcludeMapFoo2 {}');
file_put_contents($this->workingDir.'/composersrc/long/excluded/excsubpath/bar.php', '<?php class ClassExcludeMapBar {}'); file_put_contents($this->workingDir.'/composersrc/long/excluded/excsubpath/bar.php', '<?php class ClassExcludeMapBar {}');
// symlink directory in project directory in classmap
$this->fs->ensureDirectoryExists($this->workingDir.'/forks/bar/src/exclude');
$this->fs->ensureDirectoryExists($this->workingDir.'/composersrc/foo');
file_put_contents($this->workingDir.'/forks/bar/src/exclude/FooExclClass.php', '<?php class FooExclClass {};');
$target = $this->workingDir.'/forks/bar/';
$link = $this->workingDir.'/composersrc/foo/bar/';
$command = Platform::isWindows()
? 'mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $target)
: 'ln -s "' . $target . '" "' . $link;
exec($command);
$this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
// Assert that autoload_classmap.php was correctly generated. // Assert that autoload_classmap.php was correctly generated.