@@ -43,17 +43,16 @@ pub fn for_file(run_config: &RunConfig, file_path: &str, from_codeowners: bool)
43
43
for_file_optimized ( run_config, file_path)
44
44
}
45
45
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 > {
47
47
let config = config_from_path ( & run_config. config_path ) ?;
48
48
use crate :: ownership:: for_file_fast:: find_file_owners;
49
49
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 ( ) )
52
51
}
53
52
54
53
pub 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 ( ) ) )
57
56
}
58
57
59
58
pub fn version ( ) -> String {
@@ -382,13 +381,14 @@ mod tests {
382
381
no_cache : false ,
383
382
} ;
384
383
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 ] ) ;
392
392
393
393
let team = team_for_file ( & run_config, "app/consumers/deep/nesting/nestdir/deep_file.rb" )
394
394
. unwrap ( )
0 commit comments