File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use static'
22
3- const { parse } = require ( 'codeowners-utils' )
4- // NOTE(mmarchini): `codeowners-utils` doesn't respect ./ prefix,
5- // so we use micromatch
6- const micromatch = require ( 'micromatch' )
3+ const { parse, matchPattern } = require ( 'codeowners-utils' )
74
85class Owners {
96 constructor ( ownersDefinitions ) {
@@ -15,14 +12,16 @@ class Owners {
1512 }
1613
1714 getOwnersForPaths ( paths ) {
18- let ownersForPath = [ ]
15+ let ownersForPaths = [ ]
1916 for ( const { pattern, owners } of this . _ownersDefinitions ) {
20- if ( micromatch ( paths , pattern ) . length > 0 ) {
21- ownersForPath = ownersForPath . concat ( owners )
17+ for ( const path of paths ) {
18+ if ( matchPattern ( path , pattern ) ) {
19+ ownersForPaths = ownersForPaths . concat ( owners )
20+ }
2221 }
2322 }
2423 // Remove duplicates before returning
25- return ownersForPath . filter ( ( v , i ) => ownersForPath . indexOf ( v ) === i ) . sort ( )
24+ return ownersForPaths . filter ( ( v , i ) => ownersForPaths . indexOf ( v ) === i ) . sort ( )
2625 }
2726}
2827
Original file line number Diff line number Diff line change 1- . /file1 @ nodejs/test1
2- . /file2 @ nodejs/test2
3- . /file3 @ nodejs/test1 @ nodejs/test2
4- . /file4 @ nodejs/test1
5- . /file5 @ nodejs/test3
6- . /folder1 /* @ nodejs/test3
7- . /folder2 /file1. * @ nodejs/test4 @ nodejs/test5
8- . /lib /timers.js @ nodejs/team @ nodejs/team2
1+ /file1 @ nodejs/test1
2+ /file2 @ nodejs/test2
3+ /file3 @ nodejs/test1 @ nodejs/test2
4+ /file4 @ nodejs/test1
5+ /file5 @ nodejs/test3
6+ /folder1 /* @ nodejs/test3
7+ /folder2 /file1. * @ nodejs/test4 @ nodejs/test5
8+ /lib /timers.js @ nodejs/team @ nodejs/team2
You can’t perform that action at this time.
0 commit comments