File tree 1 file changed +33
-0
lines changed
crate_universe/src/metadata
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(
85
85
} )
86
86
. transpose ( ) ?;
87
87
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.
88
114
' per_child: for entry in walkdir:: WalkDir :: new ( workspace_path. parent ( ) . unwrap ( ) )
89
115
. follow_links ( false )
90
116
. follow_root_links ( false )
@@ -114,6 +140,13 @@ fn discover_workspaces_with_cache(
114
140
continue ;
115
141
}
116
142
143
+ if workspace_excludes
144
+ . iter ( )
145
+ . any ( |pattern| pattern. matches_path ( entry. path ( ) ) )
146
+ {
147
+ continue ;
148
+ }
149
+
117
150
let child_path = Utf8Path :: from_path ( entry. path ( ) )
118
151
. ok_or_else ( || anyhow ! ( "Failed to parse {:?} as UTF-8" , entry. path( ) ) ) ?
119
152
. to_path_buf ( ) ;
You can’t perform that action at this time.
0 commit comments