File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
crate_universe/src/metadata Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,32 @@ fn discover_workspaces_with_cache(
8585 } )
8686 . transpose ( ) ?;
8787
88+ let workspace_excludes = workspace_manifest
89+ . workspace
90+ . as_ref ( )
91+ . map ( |workspace| {
92+ workspace
93+ . exclude
94+ . iter ( )
95+ . map ( |pattern| {
96+ // We should always have a parent path, but be defensive here because who
97+ // knows what kind of setups folks have!
98+ let absolute_pattern = match workspace_path. parent ( ) {
99+ // Only append the parent if the pattern isn't already absolute.
100+ Some ( parent) if !pattern. starts_with ( "/" ) => {
101+ & format ! ( "{}/{pattern}" , parent. as_str( ) )
102+ }
103+ _ => pattern,
104+ } ;
105+ glob:: Pattern :: new ( absolute_pattern) . map_err ( anyhow:: Error :: from)
106+ } )
107+ . collect :: < Result < Vec < _ > , _ > > ( )
108+ } )
109+ . transpose ( ) ?
110+ . unwrap_or_default ( ) ;
111+
112+ // TODO: It would be nice if WalkDir could skip entire directories so
113+ // if you exclude a subtree we don't spend time walking down it.
88114 ' per_child: for entry in walkdir:: WalkDir :: new ( workspace_path. parent ( ) . unwrap ( ) )
89115 . follow_links ( false )
90116 . follow_root_links ( false )
@@ -114,6 +140,13 @@ fn discover_workspaces_with_cache(
114140 continue ;
115141 }
116142
143+ if workspace_excludes
144+ . iter ( )
145+ . any ( |pattern| pattern. matches_path ( entry. path ( ) ) )
146+ {
147+ continue ;
148+ }
149+
117150 let child_path = Utf8Path :: from_path ( entry. path ( ) )
118151 . ok_or_else ( || anyhow ! ( "Failed to parse {:?} as UTF-8" , entry. path( ) ) ) ?
119152 . to_path_buf ( ) ;
You can’t perform that action at this time.
0 commit comments