mirror of
https://github.com/pestphp/pest.git
synced 2026-06-05 02:52:12 +02:00
wip
This commit is contained in:
@ -108,13 +108,10 @@ final readonly class ChangedFiles
|
|||||||
if ($file === '') {
|
if ($file === '') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($this->shouldIgnore($file)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$unique[$file] = true;
|
$unique[$file] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$candidates = array_keys($unique);
|
$candidates = array_keys($this->filterIgnored($unique));
|
||||||
|
|
||||||
if ($sha !== null && $sha !== '') {
|
if ($sha !== null && $sha !== '') {
|
||||||
return $this->filterBehaviourallyUnchanged($candidates, $sha);
|
return $this->filterBehaviourallyUnchanged($candidates, $sha);
|
||||||
@ -169,24 +166,43 @@ final readonly class ChangedFiles
|
|||||||
return $process->getOutput();
|
return $process->getOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function shouldIgnore(string $path): bool
|
/**
|
||||||
|
* @param array<string, true> $candidates
|
||||||
|
* @return array<string, true>
|
||||||
|
*/
|
||||||
|
private function filterIgnored(array $candidates): array
|
||||||
{
|
{
|
||||||
static $prefixes = [
|
if ($candidates === []) {
|
||||||
'.pest/',
|
return $candidates;
|
||||||
'.phpunit.cache/',
|
}
|
||||||
'.phpunit.result.cache',
|
|
||||||
'vendor/',
|
|
||||||
'node_modules/',
|
|
||||||
'bootstrap/cache/',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($prefixes as $prefix) {
|
$process = new Process(
|
||||||
if (str_starts_with($path, (string) $prefix)) {
|
['git', 'check-ignore', '--no-index', '-z', '--stdin'],
|
||||||
return true;
|
$this->projectRoot,
|
||||||
|
);
|
||||||
|
$process->setTimeout(5.0);
|
||||||
|
$process->setInput(implode("\x00", array_keys($candidates)));
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$exitCode = $process->getExitCode();
|
||||||
|
|
||||||
|
if ($exitCode !== 0 && $exitCode !== 1) {
|
||||||
|
throw new MissingDependency('Tia mode', 'git');
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = $process->getOutput();
|
||||||
|
|
||||||
|
if ($output === '') {
|
||||||
|
return $candidates;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (explode("\x00", rtrim($output, "\x00")) as $ignored) {
|
||||||
|
if ($ignored !== '') {
|
||||||
|
unset($candidates[$ignored]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $candidates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function currentBranch(): ?string
|
public function currentBranch(): ?string
|
||||||
|
|||||||
Reference in New Issue
Block a user