This commit is contained in:
nuno maduro
2026-05-02 18:02:13 +01:00
parent e3e178fd94
commit 8ddcd3e853

View File

@ -35,37 +35,27 @@ final readonly class ChangedFiles
foreach (array_keys($candidates) as $file) { foreach (array_keys($candidates) as $file) {
$snapshot = $lastRunTree[$file] ?? null; $snapshot = $lastRunTree[$file] ?? null;
$absolute = $this->projectRoot.DIRECTORY_SEPARATOR.$file; $current = $this->currentHash($file);
$exists = is_file($absolute);
if ($snapshot === null) { if ($snapshot === null || $current === null || $current !== $snapshot) {
$remaining[] = $file; $remaining[] = $file;
}
continue;
} }
if (! $exists) { return $remaining;
$remaining[] = $file; }
continue; private function currentHash(string $relativePath): ?string
{
$absolute = $this->projectRoot.DIRECTORY_SEPARATOR.$relativePath;
if (! is_file($absolute)) {
return null;
} }
$hash = ContentHash::of($absolute); $hash = ContentHash::of($absolute);
if ($hash === false) { return $hash === false ? null : $hash;
$remaining[] = $file;
continue;
}
if ($hash === $snapshot) {
continue;
}
$remaining[] = $file;
}
return $remaining;
} }
/** /**
@ -142,17 +132,9 @@ final readonly class ChangedFiles
$remaining = []; $remaining = [];
foreach ($files as $file) { foreach ($files as $file) {
$absolute = $this->projectRoot.DIRECTORY_SEPARATOR.$file; $currentHash = $this->currentHash($file);
if (! is_file($absolute)) { if ($currentHash === null) {
$remaining[] = $file;
continue;
}
$currentHash = ContentHash::of($absolute);
if ($currentHash === false) {
$remaining[] = $file; $remaining[] = $file;
continue; continue;
@ -166,9 +148,7 @@ final readonly class ChangedFiles
continue; continue;
} }
$baselineHash = ContentHash::ofContent($file, $baselineContent); if ($currentHash !== ContentHash::ofContent($file, $baselineContent)) {
if ($currentHash !== $baselineHash) {
$remaining[] = $file; $remaining[] = $file;
} }
} }