This commit is contained in:
nuno maduro
2026-04-27 18:14:10 +01:00
parent d4c7362132
commit 339c1e8cac

View File

@ -94,28 +94,21 @@ final readonly class ChangedFiles
} }
if ($hash === $snapshot) { if ($hash === $snapshot) {
// Same state as the last TIA invocation — unchanged. // Same state as the last TIA invocation — cached
// result is still valid, no need to re-run.
continue; continue;
} }
// Differs from the snapshot, but may still be a revert back // Differs from the snapshot. This includes the
// to the committed version (scenario: last run had an edit, // revert-back-to-baseline case (last run had a real edit
// this run reverted it). Skipping this check causes stale // and was cached against that edit; this run reverted).
// snapshots from previous scenarios to cascade into the // Even though the file now matches what's at the recorded
// current run's invalidation set. Cheap to verify via // SHA, the cached test result reflects the *modified*
// `git show <sha>:<path>`. // version, not the baseline version — so it's stale and
if ($sha !== null && $sha !== '') { // the test must re-run to refresh the cache. An earlier
$baselineContent = $this->contentAtSha($sha, $file); // version of this filter short-circuited on
// matches-baseline, which served the stale failure
if ($baselineContent !== null) { // forever after the user reverted.
$baselineHash = ContentHash::ofContent($file, $baselineContent);
if ($hash === $baselineHash) {
continue;
}
}
}
$remaining[] = $file; $remaining[] = $file;
} }