@@ -2,6 +2,7 @@ use std::collections::HashMap;
22use std:: path:: PathBuf ;
33use std:: sync:: Arc ;
44
5+ use super :: escaper:: escape_brackets;
56use super :: Entry ;
67use super :: { Mapper , OwnerMatcher } ;
78use crate :: ownership:: mapper:: Source ;
@@ -30,7 +31,7 @@ impl Mapper for TeamFileMapper {
3031 let relative_path = self . project . relative_path ( & owned_file. path ) ;
3132
3233 entries. push ( Entry {
33- path : relative_path. to_string_lossy ( ) . to_string ( ) ,
34+ path : escape_brackets ( & relative_path. to_string_lossy ( ) ) ,
3435 github_team : team. github_team . to_owned ( ) ,
3536 team_name : team. name . to_owned ( ) ,
3637 disabled : team. avoid_ownership ,
@@ -70,26 +71,33 @@ impl Mapper for TeamFileMapper {
7071mod tests {
7172 use std:: error:: Error ;
7273
73- use crate :: common_test:: tests:: { build_ownership_with_all_mappers , build_ownership_with_team_file_codeowners, vecs_match} ;
74+ use crate :: common_test:: tests:: { build_ownership_with_team_file_codeowners, vecs_match} ;
7475
7576 use super :: * ;
7677 #[ test]
7778 fn test_entries ( ) -> Result < ( ) , Box < dyn Error > > {
78- let ownership = build_ownership_with_all_mappers ( ) ?;
79+ let ownership = build_ownership_with_team_file_codeowners ( ) ?;
7980 let mapper = TeamFileMapper :: build ( ownership. project . clone ( ) ) ;
81+ dbg ! ( & mapper. entries( ) ) ;
8082 vecs_match (
8183 & mapper. entries ( ) ,
8284 & vec ! [
85+ Entry {
86+ path: "packs/\\ [admin\\ ]/comp.ts" . to_owned( ) ,
87+ github_team: "@Bar" . to_owned( ) ,
88+ team_name: "Bar" . to_owned( ) ,
89+ disabled: false ,
90+ } ,
8391 Entry {
8492 path: "packs/jscomponents/comp.ts" . to_owned( ) ,
8593 github_team: "@Foo" . to_owned( ) ,
8694 team_name: "Foo" . to_owned( ) ,
8795 disabled: false ,
8896 } ,
8997 Entry {
90- path: "packs/zebra/app/services/team_file_owned .rb" . to_owned( ) ,
91- github_team: "@Foo " . to_owned( ) ,
92- team_name: "Foo " . to_owned( ) ,
98+ path: "packs/bar/comp .rb" . to_owned( ) ,
99+ github_team: "@Bar " . to_owned( ) ,
100+ team_name: "Bar " . to_owned( ) ,
93101 disabled: false ,
94102 } ,
95103 ] ,
@@ -102,7 +110,14 @@ mod tests {
102110 let ownership = build_ownership_with_team_file_codeowners ( ) ?;
103111 let mapper = TeamFileMapper :: build ( ownership. project . clone ( ) ) ;
104112 let owner_matchers = mapper. owner_matchers ( ) ;
105- let expected_owner_matchers = vec ! [ OwnerMatcher :: ExactMatches ( HashMap :: new( ) , Source :: TeamFile ) ] ;
113+ let expected_owner_matchers = vec ! [ OwnerMatcher :: ExactMatches (
114+ HashMap :: from( [
115+ ( PathBuf :: from( "packs/[admin]/comp.ts" ) , "Bar" . to_owned( ) ) ,
116+ ( PathBuf :: from( "packs/bar/comp.rb" ) , "Bar" . to_owned( ) ) ,
117+ ( PathBuf :: from( "packs/jscomponents/comp.ts" ) , "Foo" . to_owned( ) ) ,
118+ ] ) ,
119+ Source :: TeamFile ,
120+ ) ] ;
106121 assert_eq ! ( owner_matchers, expected_owner_matchers) ;
107122 Ok ( ( ) )
108123 }
0 commit comments