feat(tia): let a project leave paths out of read capture (#2030)

* feat(tia): let a project leave paths out of read capture

* Verify TIA watch fallbacks and refresh snapshots

---------

Co-authored-by: Sylvain Valienne <2300259+sylouuu@users.noreply.github.com>
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
This commit is contained in:
Syl
2026-11-20 14:11:03 +01:00
committed by GitHub
parent fdc57f77b7
commit 41af35a3f2
8 changed files with 366 additions and 3 deletions
+42
View File
@@ -43,6 +43,13 @@ final class WatchPatterns
private bool $defaultsEnabled = true;
/**
* @var list<string>
*/
private array $excludedReadPatterns = [];
private bool $readCaptureEnabled = true;
/**
* @var array<string, array{include: string, excludes: array<int, string>, allowDotfiles: bool}>
*/
@@ -110,6 +117,39 @@ final class WatchPatterns
]));
}
/**
* @param list<string>|null $patterns
*/
public function excludeReads(?array $patterns = null): void
{
if ($patterns === null) {
$this->readCaptureEnabled = false;
return;
}
$this->excludedReadPatterns = array_values(array_unique([
...$this->excludedReadPatterns,
...$patterns,
]));
}
public function isReadCaptureEnabled(): bool
{
return $this->readCaptureEnabled;
}
/**
* @param string $file Project-relative path.
*/
public function excludesRead(string $file): bool
{
return array_any(
$this->excludedReadPatterns,
fn (string $pattern): bool => $this->keyMatches($pattern, $file),
);
}
/**
* @param string $projectRoot Absolute path.
* @param array<int, string> $changedFiles Project-relative paths.
@@ -279,6 +319,8 @@ final class WatchPatterns
$this->defaultPatterns = [];
$this->excludedDefaultPatterns = [];
$this->defaultsEnabled = true;
$this->excludedReadPatterns = [];
$this->readCaptureEnabled = true;
$this->parsed = [];
$this->enabled = false;
$this->locally = false;