Skip to content

Commit

Permalink
Support multiple owners per glob (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdzhang authored Apr 10, 2024
1 parent 79a6caa commit 7145304
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 9 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,18 @@ export async function getCodeowners(
.filter(l => l.trim().length > 0)
.filter(l => !l.startsWith('#'))
.map(l => l.split(' '))
.filter(([glob, team]) => {
if (team === undefined) {
.filter(([glob, ...teams]) => {
if (
teams.length === 0 ||
(teams.length === 1 && teams[0] === undefined)
) {
core.warning(`CODEOWNERS had glob ${glob} w/o matching team`)
return false
}

return team !== undefined
return true
})
.map(([glob, team]) => {
.map(([glob, ...teams]) => {
// do some munging to support CODEOWNER format globs
let finalGlob = glob

Expand All @@ -125,8 +129,9 @@ export async function getCodeowners(
}
}

return [finalGlob, team]
return teams.map(team => [finalGlob, team])
})
.flat(1)

if (!codeowners.length) {
core.warning(`Pull request #${prNumber} has no codeowners`)
Expand Down

0 comments on commit 7145304

Please sign in to comment.