@@ -16,15 +16,17 @@ use std::{
1616use vite_path:: AbsolutePathBuf ;
1717use vite_path:: { AbsolutePath , RelativePathBuf } ;
1818use vite_str:: Str ;
19- use wax:: { Glob , Program as _, walk:: Entry as _} ;
19+ use wax:: {
20+ Glob ,
21+ walk:: { Entry as _, FileIterator as _} ,
22+ } ;
2023
21- /// Collect walk entries into the result map, filtering against resolved negatives .
24+ /// Collect walk entries into the result map.
2225///
2326/// Walk errors for non-existent directories are skipped gracefully.
2427fn collect_walk_entries (
2528 walk : impl Iterator < Item = Result < wax:: walk:: GlobEntry , wax:: walk:: WalkError > > ,
2629 workspace_root : & AbsolutePath ,
27- resolved_negatives : & [ Glob < ' static > ] ,
2830 result : & mut BTreeMap < RelativePathBuf , u64 > ,
2931) -> anyhow:: Result < ( ) > {
3032 for entry in walk {
@@ -54,11 +56,6 @@ fn collect_walk_entries(
5456 continue ; // Skip if path is outside workspace_root
5557 } ;
5658
57- // Filter against resolved negatives (both are workspace-root-relative)
58- if resolved_negatives. iter ( ) . any ( |neg| neg. is_match ( relative_to_workspace. as_str ( ) ) ) {
59- continue ;
60- }
61-
6259 // Hash file content
6360 match hash_file_content ( path) {
6461 Ok ( hash) => {
@@ -97,46 +94,27 @@ pub fn compute_globbed_inputs(
9794 return Ok ( BTreeMap :: new ( ) ) ;
9895 }
9996
100- let resolved_negatives: Vec < Glob < ' static > > = negative_globs
101- . iter ( )
102- . map ( |p| Ok ( Glob :: new ( p. as_str ( ) ) ?. into_owned ( ) ) )
103- . collect :: < anyhow:: Result < _ > > ( ) ?;
97+ let negation = if negative_globs. is_empty ( ) {
98+ None
99+ } else {
100+ let negatives: Vec < Glob < ' static > > = negative_globs
101+ . iter ( )
102+ . map ( |p| Ok ( Glob :: new ( p. as_str ( ) ) ?. into_owned ( ) ) )
103+ . collect :: < anyhow:: Result < _ > > ( ) ?;
104+ Some ( wax:: any ( negatives) ?)
105+ } ;
104106
105107 let mut result = BTreeMap :: new ( ) ;
106108
107109 for pattern in positive_globs {
108- let pos = Glob :: new ( pattern. as_str ( ) ) ?. into_owned ( ) ;
109- let ( pos_prefix, pos_variant) = pos. partition ( ) ;
110- let walk_root = workspace_root. as_path ( ) . join ( & pos_prefix) ;
111-
112- if let Some ( variant_glob) = pos_variant {
113- if walk_root. is_dir ( ) {
114- collect_walk_entries (
115- variant_glob. into_owned ( ) . walk ( & walk_root) ,
116- workspace_root,
117- & resolved_negatives,
118- & mut result,
119- ) ?;
110+ let glob = Glob :: new ( pattern. as_str ( ) ) ?. into_owned ( ) ;
111+ let walk = glob. walk ( workspace_root. as_path ( ) ) ;
112+ match & negation {
113+ Some ( negation) => {
114+ collect_walk_entries ( walk. not ( negation. clone ( ) ) ?, workspace_root, & mut result) ?;
120115 }
121- } else {
122- // Invariant-only glob (specific file path) — hash directly if it exists
123- if walk_root. is_file ( )
124- && let Some ( relative) = walk_root
125- . strip_prefix ( workspace_root. as_path ( ) )
126- . ok ( )
127- . and_then ( |p| RelativePathBuf :: new ( p) . ok ( ) )
128- {
129- // Check against negatives
130- if resolved_negatives. iter ( ) . any ( |neg| neg. is_match ( relative. as_str ( ) ) ) {
131- continue ;
132- }
133- match hash_file_content ( & walk_root) {
134- Ok ( hash) => {
135- result. insert ( relative, hash) ;
136- }
137- Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => { }
138- Err ( err) => return Err ( err. into ( ) ) ,
139- }
116+ None => {
117+ collect_walk_entries ( walk, workspace_root, & mut result) ?;
140118 }
141119 }
142120 }
0 commit comments