@@ -17,10 +17,7 @@ pub fn find_file_owners(project_root: &Path, config: &Config, file_path: &Path)
1717 } else {
1818 project_root. join ( file_path)
1919 } ;
20- let relative_file_path = absolute_file_path
21- . strip_prefix ( project_root)
22- . unwrap_or ( & absolute_file_path)
23- . to_path_buf ( ) ;
20+ let relative_file_path = crate :: path_utils:: relative_to_buf ( project_root, & absolute_file_path) ;
2421
2522 let teams = load_teams ( project_root, & config. team_file_glob ) ?;
2623 let teams_by_name = build_teams_by_name_map ( & teams) ;
@@ -68,7 +65,7 @@ pub fn find_file_owners(project_root: &Path, config: &Config, file_path: &Path)
6865 }
6966
7067 for team in & teams {
71- let team_rel = team . path . strip_prefix ( project_root) . unwrap_or ( & team. path ) . to_path_buf ( ) ;
68+ let team_rel = crate :: path_utils :: relative_to_buf ( project_root, & team. path ) ;
7269 if team_rel == relative_file_path {
7370 sources_by_team. entry ( team. name . clone ( ) ) . or_default ( ) . push ( Source :: TeamYml ) ;
7471 }
@@ -77,10 +74,7 @@ pub fn find_file_owners(project_root: &Path, config: &Config, file_path: &Path)
7774 let mut file_owners: Vec < FileOwner > = Vec :: new ( ) ;
7875 for ( team_name, sources) in sources_by_team. into_iter ( ) {
7976 if let Some ( team) = teams_by_name. get ( & team_name) {
80- let relative_team_yml_path = team
81- . path
82- . strip_prefix ( project_root)
83- . unwrap_or ( & team. path )
77+ let relative_team_yml_path = crate :: path_utils:: relative_to ( project_root, & team. path )
8478 . to_string_lossy ( )
8579 . to_string ( ) ;
8680 file_owners. push ( FileOwner {
@@ -157,9 +151,7 @@ fn most_specific_directory_owner(
157151 if let Ok ( owner_str) = fs:: read_to_string ( & codeowner_path) {
158152 let owner = owner_str. trim ( ) ;
159153 if let Some ( team) = teams_by_name. get ( owner) {
160- let relative_dir = current
161- . strip_prefix ( project_root)
162- . unwrap_or ( current. as_path ( ) )
154+ let relative_dir = crate :: path_utils:: relative_to ( project_root, current. as_path ( ) )
163155 . to_string_lossy ( )
164156 . to_string ( ) ;
165157 let candidate = ( team. name . clone ( ) , Source :: Directory ( relative_dir) ) ;
@@ -191,7 +183,7 @@ fn nearest_package_owner(
191183 if !current. pop ( ) {
192184 break ;
193185 }
194- let parent_rel = current . strip_prefix ( project_root) . unwrap_or ( current. as_path ( ) ) ;
186+ let parent_rel = crate :: path_utils :: relative_to ( project_root, current. as_path ( ) ) ;
195187 if let Some ( rel_str) = parent_rel. to_str ( ) {
196188 if glob_list_matches ( rel_str, & config. ruby_package_paths ) {
197189 let pkg_yml = current. join ( "package.yml" ) ;
0 commit comments