@@ -43,17 +43,16 @@ pub fn for_file(run_config: &RunConfig, file_path: &str, from_codeowners: bool)
4343 for_file_optimized ( run_config, file_path)
4444}
4545
46- pub fn file_owners_for_file ( run_config : & RunConfig , file_path : & str ) -> Result < Vec < FileOwner > , Error > {
46+ pub fn file_owner_for_file ( run_config : & RunConfig , file_path : & str ) -> Result < Option < FileOwner > , Error > {
4747 let config = config_from_path ( & run_config. config_path ) ?;
4848 use crate :: ownership:: for_file_fast:: find_file_owners;
4949 let owners = find_file_owners ( & run_config. project_root , & config, std:: path:: Path :: new ( file_path) ) . map_err ( Error :: Io ) ?;
50-
51- Ok ( owners)
50+ Ok ( owners. first ( ) . cloned ( ) )
5251}
5352
5453pub fn team_for_file ( run_config : & RunConfig , file_path : & str ) -> Result < Option < Team > , Error > {
55- let owners = file_owners_for_file ( run_config, file_path) ?;
56- Ok ( owners . first ( ) . map ( |fo| fo. team . clone ( ) ) )
54+ let owner = file_owner_for_file ( run_config, file_path) ?;
55+ Ok ( owner . map ( |fo| fo. team . clone ( ) ) )
5756}
5857
5958pub fn version ( ) -> String {
@@ -382,13 +381,14 @@ mod tests {
382381 no_cache : false ,
383382 } ;
384383
385- let file_owners = file_owners_for_file ( & run_config, "app/consumers/deep/nesting/nestdir/deep_file.rb" ) . unwrap ( ) ;
386- assert_eq ! ( file_owners. len( ) , 1 ) ;
387- assert_eq ! ( file_owners[ 0 ] . team. name, "b" ) ;
388- assert_eq ! ( file_owners[ 0 ] . team. github_team, "@b" ) ;
389- assert ! ( file_owners[ 0 ] . team. path. to_string_lossy( ) . ends_with( "config/teams/b.yml" ) ) ;
390- assert_eq ! ( file_owners[ 0 ] . sources. len( ) , 1 ) ;
391- assert_eq ! ( file_owners[ 0 ] . sources, vec![ Source :: AnnotatedFile ] ) ;
384+ let file_owner = file_owner_for_file ( & run_config, "app/consumers/deep/nesting/nestdir/deep_file.rb" )
385+ . unwrap ( )
386+ . unwrap ( ) ;
387+ assert_eq ! ( file_owner. team. name, "b" ) ;
388+ assert_eq ! ( file_owner. team. github_team, "@b" ) ;
389+ assert ! ( file_owner. team. path. to_string_lossy( ) . ends_with( "config/teams/b.yml" ) ) ;
390+ assert_eq ! ( file_owner. sources. len( ) , 1 ) ;
391+ assert_eq ! ( file_owner. sources, vec![ Source :: AnnotatedFile ] ) ;
392392
393393 let team = team_for_file ( & run_config, "app/consumers/deep/nesting/nestdir/deep_file.rb" )
394394 . unwrap ( )
0 commit comments