mirror of
https://github.com/pestphp/pest.git
synced 2026-06-07 20:02:13 +02:00
wip
This commit is contained in:
@ -35,39 +35,29 @@ 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) {
|
|
||||||
$remaining[] = $file;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$hash = ContentHash::of($absolute);
|
|
||||||
|
|
||||||
if ($hash === false) {
|
|
||||||
$remaining[] = $file;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($hash === $snapshot) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$remaining[] = $file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $remaining;
|
return $remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function currentHash(string $relativePath): ?string
|
||||||
|
{
|
||||||
|
$absolute = $this->projectRoot.DIRECTORY_SEPARATOR.$relativePath;
|
||||||
|
|
||||||
|
if (! is_file($absolute)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hash = ContentHash::of($absolute);
|
||||||
|
|
||||||
|
return $hash === false ? null : $hash;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<int, string> $files
|
* @param array<int, string> $files
|
||||||
* @return array<string, string> path → xxh128 content hash
|
* @return array<string, string> path → xxh128 content hash
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user