Skip to content

Commit 1999f82

Browse files
committed
fix(owners): path shouldn't start with .
1 parent e64662f commit 1999f82

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

lib/node-owners.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
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

85
class 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

package-lock.json

+7-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"express": "^4.13.4",
2828
"glob": "^7.0.3",
2929
"lru-cache": "^4.0.1",
30-
"micromatch": "^4.0.2",
3130
"request": "^2.88.0"
3231
},
3332
"devDependencies": {

test/_fixtures/CODEOWNERS

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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

0 commit comments

Comments
 (0)