fix(cs-fixer): Correctly ignore files ignored by git

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/47474/head
provokateurin 2024-08-25 20:40:47 +07:00
parent 5d632154c2
commit ffc8a86d7d
No known key found for this signature in database
1 changed files with 13 additions and 19 deletions

@ -14,29 +14,23 @@ $config = new Config();
$config $config
->setParallelConfig(ParallelConfigFactory::detect()) ->setParallelConfig(ParallelConfigFactory::detect())
->getFinder() ->getFinder()
->ignoreVCSIgnored(true)
->exclude('config') ->exclude('config')
->exclude('data') ->exclude('3rdparty')
->notPath('3rdparty') ->exclude('build/stubs')
->notPath('build/integration/vendor') ->exclude('composer')
->notPath('build/lib')
->notPath('build/node_modules')
->notPath('build/stubs')
->notPath('composer')
->notPath('node_modules')
->notPath('vendor')
->in('apps')
->in(__DIR__); ->in(__DIR__);
// Ignore additional app directories $ignoredEntries = shell_exec('git status --porcelain --ignored ' . escapeshellarg(__DIR__));
$rootDir = new \DirectoryIterator(__DIR__); $ignoredEntries = explode("\n", $ignoredEntries);
foreach ($rootDir as $node) { $ignoredEntries = array_filter($ignoredEntries, static fn (string $line) => str_starts_with($line, '!! '));
if (str_starts_with($node->getFilename(), 'apps')) { $ignoredEntries = array_map(static fn (string $line) => substr($line, 3), $ignoredEntries);
$return = shell_exec('git check-ignore ' . escapeshellarg($node->getFilename() . '/')); $ignoredEntries = array_values($ignoredEntries);
if ($return !== null) { foreach ($ignoredEntries as $ignoredEntry) {
$config->getFinder()->exclude($node->getFilename()); if (str_ends_with($ignoredEntry, '/')) {
} $config->getFinder()->exclude($ignoredEntry);
} else {
$config->getFinder()->notPath($ignoredEntry);
} }
} }