File tree Expand file tree Collapse file tree 4 files changed +468
-18
lines changed Expand file tree Collapse file tree 4 files changed +468
-18
lines changed Original file line number Diff line number Diff line change @@ -662,11 +662,11 @@ impl Builder {
662662 } else {
663663 for wm in & workspace_members {
664664 if let Ok ( i) = packages. binary_search_by ( |( id, _pkg) | id. cmp ( wm) ) {
665- if self
666- . workspace_filters
667- . iter ( )
668- . any ( |wf| wf == & packages [ i ] . 1 . manifest_path )
669- {
665+ let mp = packages [ i ] . 1 . manifest_path . as_std_path ( ) ;
666+ let manifest_path = mp . canonicalize ( ) ;
667+
668+ let mp = manifest_path . as_deref ( ) . unwrap_or ( mp ) ;
669+ if self . workspace_filters . iter ( ) . any ( |wf| wf == mp ) {
670670 roots. insert ( wm) ;
671671 }
672672 }
Original file line number Diff line number Diff line change @@ -60,19 +60,16 @@ pub struct Metadata {
6060impl Metadata {
6161 /// Get the workspace's root package of this metadata instance.
6262 pub fn root_package ( & self ) -> Option < & Package > {
63- match & self . resolve {
64- Some ( resolve) => {
65- // if dependencies are resolved, use Cargo's answer
66- let root = resolve. root . as_ref ( ) ?;
67- self . packages . iter ( ) . find ( |pkg| & pkg. id == root)
68- }
69- None => {
70- // if dependencies aren't resolved, check for a root package manually
71- let root_manifest_path = self . workspace_root . join ( "Cargo.toml" ) ;
72- self . packages
73- . iter ( )
74- . find ( |pkg| pkg. manifest_path == root_manifest_path)
75- }
63+ if let Some ( resolve) = & self . resolve {
64+ // if dependencies are resolved, use Cargo's answer
65+ let root = resolve. root . as_ref ( ) ?;
66+ self . packages . iter ( ) . find ( |pkg| & pkg. id == root)
67+ } else {
68+ // if dependencies aren't resolved, check for a root package manually
69+ let root_manifest_path = self . workspace_root . join ( "Cargo.toml" ) ;
70+ self . packages
71+ . iter ( )
72+ . find ( |pkg| pkg. manifest_path == root_manifest_path)
7673 }
7774 }
7875
Original file line number Diff line number Diff line change @@ -13,6 +13,16 @@ fn excludes_workspace_member() {
1313 insta:: assert_snapshot!( grafs. dotgraph( ) ) ;
1414}
1515
16+ #[ test]
17+ fn includes_by_path ( ) {
18+ let mut kb = krates:: Builder :: new ( ) ;
19+ kb. include_workspace_crates ( [ "/home/jake/code/krates/tests/ws/c" ] ) ;
20+
21+ let grafs = build ( "all-features.json" , kb) . unwrap ( ) ;
22+
23+ insta:: assert_snapshot!( grafs. dotgraph( ) ) ;
24+ }
25+
1626#[ test]
1727fn excludes_dependencies ( ) {
1828 let mut kb = krates:: Builder :: new ( ) ;
You can’t perform that action at this time.
0 commit comments