-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ping teams based on which files were changed
Using .github/CODEOWNERS, `github-bot` will ping the appropriate teams based on which files were changed in a Pull Request. This feature is inteded to work around GitHub's limitation which prevents teams without explicit write access from being added as reviewers (thus preventing the vast majority of teams in the org from being used on GitHub's CODEOWNERS feature). Ref: nodejs/node#33984
- Loading branch information
Showing
12 changed files
with
880 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use static' | ||
|
||
const { parse } = require('codeowners-utils') | ||
// NOTE(mmarchini): `codeowners-utils` doesn't respect ./ prefix, | ||
// so we use micromatch | ||
const micromatch = require('micromatch') | ||
|
||
class Owners { | ||
constructor (ownersDefinitions) { | ||
this._ownersDefinitions = ownersDefinitions | ||
} | ||
|
||
static fromFile (content) { | ||
return new Owners(parse(content)) | ||
} | ||
|
||
getOwnersForPaths (paths) { | ||
let ownersForPath = [] | ||
for (const { pattern, owners } of this._ownersDefinitions) { | ||
if (micromatch(paths, pattern).length > 0) { | ||
ownersForPath = ownersForPath.concat(owners) | ||
} | ||
} | ||
// Remove duplicates before returning | ||
return ownersForPath.filter((v, i) => ownersForPath.indexOf(v) === i).sort() | ||
} | ||
} | ||
|
||
module.exports = { | ||
Owners | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.