@@ -82,7 +82,10 @@ pub enum WorkspaceConfig {
82
82
Member { root : Option < String > } ,
83
83
}
84
84
85
- /// Configuration of a workspace root in a manifest.
85
+ /// Intermediate configuration of a workspace root in a manifest.
86
+ ///
87
+ /// Knows the Workspace Root path, as well as `members` and `exclude` lists of path patterns, which
88
+ /// together tell if some path is recognized as a member by this root or not.
86
89
#[ derive( Debug , Clone ) ]
87
90
pub struct WorkspaceRootConfig {
88
91
root_dir : PathBuf ,
@@ -207,7 +210,7 @@ impl<'cfg> Workspace<'cfg> {
207
210
let root = self . root_manifest . as_ref ( ) . unwrap_or ( & self . current_manifest ) ;
208
211
match * self . packages . get ( root) {
209
212
MaybePackage :: Package ( ref p) => p. manifest ( ) . profiles ( ) ,
210
- MaybePackage :: Virtual ( ref m ) => m . profiles ( ) ,
213
+ MaybePackage :: Virtual ( ref vm ) => vm . profiles ( ) ,
211
214
}
212
215
}
213
216
@@ -238,7 +241,7 @@ impl<'cfg> Workspace<'cfg> {
238
241
} ;
239
242
match * self . packages . get ( path) {
240
243
MaybePackage :: Package ( ref p) => p. manifest ( ) . replace ( ) ,
241
- MaybePackage :: Virtual ( ref v ) => v . replace ( ) ,
244
+ MaybePackage :: Virtual ( ref vm ) => vm . replace ( ) ,
242
245
}
243
246
}
244
247
@@ -252,7 +255,7 @@ impl<'cfg> Workspace<'cfg> {
252
255
} ;
253
256
match * self . packages . get ( path) {
254
257
MaybePackage :: Package ( ref p) => p. manifest ( ) . patch ( ) ,
255
- MaybePackage :: Virtual ( ref v ) => v . patch ( ) ,
258
+ MaybePackage :: Virtual ( ref vm ) => vm . patch ( ) ,
256
259
}
257
260
}
258
261
@@ -306,20 +309,20 @@ impl<'cfg> Workspace<'cfg> {
306
309
}
307
310
308
311
for path in paths:: ancestors ( manifest_path) . skip ( 2 ) {
309
- let manifest = path. join ( "Cargo.toml" ) ;
310
- debug ! ( "find_root - trying {}" , manifest . display( ) ) ;
311
- if manifest . exists ( ) {
312
- match * self . packages . load ( & manifest ) ?. workspace_config ( ) {
313
- WorkspaceConfig :: Root ( ref root_config ) => {
312
+ let ances_manifest_path = path. join ( "Cargo.toml" ) ;
313
+ debug ! ( "find_root - trying {}" , ances_manifest_path . display( ) ) ;
314
+ if ances_manifest_path . exists ( ) {
315
+ match * self . packages . load ( & ances_manifest_path ) ?. workspace_config ( ) {
316
+ WorkspaceConfig :: Root ( ref ances_root_config ) => {
314
317
debug ! ( "find_root - found a root checking exclusion" ) ;
315
- if !root_config . is_excluded ( manifest_path) {
318
+ if !ances_root_config . is_excluded ( & manifest_path) {
316
319
debug ! ( "find_root - found!" ) ;
317
- return Ok ( Some ( manifest ) )
320
+ return Ok ( Some ( ances_manifest_path ) )
318
321
}
319
322
}
320
323
WorkspaceConfig :: Member { root : Some ( ref path_to_root) } => {
321
324
debug ! ( "find_root - found pointer" ) ;
322
- return Ok ( Some ( read_root_pointer ( & manifest , path_to_root) ?) )
325
+ return Ok ( Some ( read_root_pointer ( & ances_manifest_path , path_to_root) ?) )
323
326
}
324
327
WorkspaceConfig :: Member { .. } => { }
325
328
}
@@ -491,6 +494,8 @@ impl<'cfg> Workspace<'cfg> {
491
494
let current_dir = self . current_manifest . parent ( ) . unwrap ( ) ;
492
495
let root_pkg = self . packages . get ( root) ;
493
496
497
+ // FIXME: Make this more generic by using a relative path resolver between member and
498
+ // root.
494
499
let members_msg = match current_dir. strip_prefix ( root_dir) {
495
500
Ok ( rel) => {
496
501
format ! ( "this may be fixable by adding `{}` to the \
@@ -578,11 +583,10 @@ impl<'cfg> Packages<'cfg> {
578
583
read_manifest ( manifest_path, & source_id, self . config ) ?;
579
584
Ok ( v. insert ( match manifest {
580
585
EitherManifest :: Real ( manifest) => {
581
- MaybePackage :: Package ( Package :: new ( manifest,
582
- manifest_path) )
586
+ MaybePackage :: Package ( Package :: new ( manifest, manifest_path) )
583
587
}
584
- EitherManifest :: Virtual ( v ) => {
585
- MaybePackage :: Virtual ( v )
588
+ EitherManifest :: Virtual ( vm ) => {
589
+ MaybePackage :: Virtual ( vm )
586
590
}
587
591
} ) )
588
592
}
@@ -616,13 +620,14 @@ impl<'a, 'cfg> Iterator for Members<'a, 'cfg> {
616
620
impl MaybePackage {
617
621
fn workspace_config ( & self ) -> & WorkspaceConfig {
618
622
match * self {
619
- MaybePackage :: Virtual ( ref v ) => v . workspace_config ( ) ,
620
- MaybePackage :: Package ( ref v ) => v . manifest ( ) . workspace_config ( ) ,
623
+ MaybePackage :: Package ( ref p ) => p . manifest ( ) . workspace_config ( ) ,
624
+ MaybePackage :: Virtual ( ref vm ) => vm . workspace_config ( ) ,
621
625
}
622
626
}
623
627
}
624
628
625
629
impl WorkspaceRootConfig {
630
+ /// Create a new Intermediate Workspace Root configuration.
626
631
pub fn new (
627
632
root_dir : & Path ,
628
633
members : & Option < Vec < String > > ,
@@ -635,6 +640,9 @@ impl WorkspaceRootConfig {
635
640
}
636
641
}
637
642
643
+ /// Checks the path against the `excluded` list.
644
+ ///
645
+ /// This method does NOT consider the `members` list.
638
646
fn is_excluded ( & self , manifest_path : & Path ) -> bool {
639
647
let excluded = self . exclude . iter ( ) . any ( |ex| {
640
648
manifest_path. starts_with ( self . root_dir . join ( ex) )
0 commit comments