Skip to content

Commit 078f722

Browse files
claudebranchseer
authored andcommitted
Fold all fspy path filtering into strip_path_prefix callback
Move .git filtering and negative glob filtering into the strip_path_prefix callback alongside path cleaning, so rejected paths return None immediately in one pass. https://claude.ai/code/session_01PR9yhnScRoVoHUcviV47u5
1 parent a738020 commit 078f722

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

  • crates/vite_task/src/session/execute

crates/vite_task/src/session/execute/spawn.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ pub async fn spawn_with_tracking(
190190
let path_writes = &mut path_accesses.path_writes;
191191

192192
for access in termination.path_accesses.iter() {
193-
// Clean the path to normalize `..` components since fspy may report
194-
// paths like `packages/sub-pkg/../shared/dist/output.js`.
193+
// Strip workspace root, clean `..` components, and filter in one pass.
194+
// fspy may report paths like `packages/sub-pkg/../shared/dist/output.js`.
195195
let relative_path = access.path.strip_path_prefix(workspace_root, |strip_result| {
196196
let Ok(stripped_path) = strip_result else {
197197
return None;
@@ -200,24 +200,25 @@ pub async fn spawn_with_tracking(
200200
// For example: c:\workspace\subdir\c:\workspace\subdir
201201
// Just ignore those accesses.
202202
let cleaned = path_clean::PathClean::clean(stripped_path);
203-
RelativePathBuf::new(cleaned).ok()
203+
let relative = RelativePathBuf::new(cleaned).ok()?;
204+
205+
// Skip .git directory accesses (workaround for tools like oxlint)
206+
if relative.as_path().strip_prefix(".git").is_ok() {
207+
return None;
208+
}
209+
210+
// Filter against resolved negative globs (both are workspace-root-relative)
211+
if resolved_negatives.iter().any(|neg| neg.is_match(relative.as_str())) {
212+
return None;
213+
}
214+
215+
Some(relative)
204216
});
205217

206218
let Some(relative_path) = relative_path else {
207-
// Ignore accesses outside the workspace
208219
continue;
209220
};
210221

211-
// Skip .git directory accesses (workaround for tools like oxlint)
212-
if relative_path.as_path().strip_prefix(".git").is_ok() {
213-
continue;
214-
}
215-
216-
// Filter against resolved negative globs (both are workspace-root-relative).
217-
if resolved_negatives.iter().any(|neg| neg.is_match(relative_path.as_str())) {
218-
continue;
219-
}
220-
221222
if access.mode.contains(AccessMode::READ) {
222223
path_reads.entry(relative_path.clone()).or_insert(PathRead { read_dir_entries: false });
223224
}

0 commit comments

Comments
 (0)