@@ -10,14 +10,13 @@ use std::{
1010 io:: { self , Read } ,
1111} ;
1212
13+ use vite_glob:: AnchoredGlob ;
1314#[ cfg( test) ]
1415use vite_path:: AbsolutePathBuf ;
1516use vite_path:: { AbsolutePath , RelativePathBuf } ;
1617use vite_str:: Str ;
1718use wax:: { Glob , walk:: Entry as _} ;
1819
19- use super :: spawn:: ResolvedNegativeGlob ;
20-
2120/// Collect walk entries into the result map, filtering against resolved negatives.
2221///
2322/// Each positive glob is partitioned into an invariant prefix and a variant pattern.
@@ -28,11 +27,10 @@ use super::spawn::ResolvedNegativeGlob;
2827fn collect_walk_entries (
2928 walk : impl Iterator < Item = Result < wax:: walk:: GlobEntry , wax:: walk:: WalkError > > ,
3029 workspace_root : & AbsolutePath ,
31- resolved_negatives : & [ ResolvedNegativeGlob ] ,
30+ resolved_negatives : & [ AnchoredGlob ] ,
3231 result : & mut BTreeMap < RelativePathBuf , u64 > ,
3332) -> anyhow:: Result < ( ) > {
3433 use path_clean:: PathClean as _;
35- use wax:: Program as _;
3634
3735 for entry in walk {
3836 let entry = match entry {
@@ -53,21 +51,18 @@ fn collect_walk_entries(
5351 // Clean the path to normalize `..` components (from globs like `../shared/src/**`)
5452 let cleaned_path = entry. path ( ) . clean ( ) ;
5553
54+ // Convert to AbsolutePath for negative matching and workspace-relative stripping
55+ let Some ( cleaned_abs) = AbsolutePath :: new ( & cleaned_path) else {
56+ continue ;
57+ } ;
58+
5659 // Filter against resolved negatives
57- if resolved_negatives. iter ( ) . any ( |( prefix, variant) | {
58- let Ok ( remainder) = cleaned_path. strip_prefix ( prefix) else {
59- return false ;
60- } ;
61- variant. as_ref ( ) . map_or ( remainder. as_os_str ( ) . is_empty ( ) , |v| v. is_match ( remainder) )
62- } ) {
60+ if resolved_negatives. iter ( ) . any ( |neg| neg. is_match ( cleaned_abs) ) {
6361 continue ;
6462 }
6563
6664 // Compute path relative to workspace_root for the result
67- let Some ( relative_to_workspace) = cleaned_path
68- . strip_prefix ( workspace_root. as_path ( ) )
69- . ok ( )
70- . and_then ( |p| RelativePathBuf :: new ( p) . ok ( ) )
65+ let Some ( relative_to_workspace) = cleaned_abs. strip_prefix ( workspace_root) . ok ( ) . flatten ( )
7166 else {
7267 continue ; // Skip if path is outside workspace_root
7368 } ;
@@ -116,15 +111,9 @@ pub fn compute_globbed_inputs(
116111 return Ok ( BTreeMap :: new ( ) ) ;
117112 }
118113
119- // Resolve negatives: partition + clean to get (absolute_prefix, variant)
120- let resolved_negatives: Vec < ResolvedNegativeGlob > = negative_globs
114+ let resolved_negatives: Vec < AnchoredGlob > = negative_globs
121115 . iter ( )
122- . map ( |p| {
123- let glob = Glob :: new ( p. as_str ( ) ) ?. into_owned ( ) ;
124- let ( prefix, variant) = glob. partition ( ) ;
125- let resolved = base_dir. as_path ( ) . join ( & prefix) . clean ( ) ;
126- Ok ( ( resolved, variant. map ( Glob :: into_owned) ) )
127- } )
116+ . map ( |p| Ok ( AnchoredGlob :: new ( p. as_str ( ) , base_dir) ?) )
128117 . collect :: < anyhow:: Result < _ > > ( ) ?;
129118
130119 let mut result = BTreeMap :: new ( ) ;
0 commit comments