@pvm/cowners
A library for working with CODEOWNERS file.
Usage
const { readCodeOwners } = require('@pvm/cowners')
async function main() {
const codeOwners = await readCodeOwners()
}
Interfaces
OwnersEntry
Structure which holds each valid line with pattern and owners in CODEWNERS file. Here is typescript definition:
interface OwnersGroup {
attrs: Record<string, string | number | boolean | null>,
pattern: string,
owners: string[],
match(path: string): boolean,
}
Where attrs
are being parsed from shebang comments.
Example shebang comment with all available cases:
#! int=4 str='cat\'s ball' new=false old=true greet="hello world!" vs=null
* @owners
Api
getGroups(): OwnersGroup[]
Returns all OwnersGroups which has been parsed.
affectedGroups(paths: string[]): IterableIterator<OwnersGroup>
Returns OwnersGroups which related to given paths.
getOwners(paths: string[]): string[]
Get all owners for given paths.
getMajority(paths: string[], opts: GetMajorityOpts = {}): string[]
Get majority of owners required for review merge request.
For each mask majority is Math.ceil(owners_for_mask / 2)
.
GetMajorityOpts.initial
List if initial reviewers.
GetMajorityOpts.exclude
List of reviewers which should be excluded from result.
groupOwnersByMask(paths: string[]): Record<string, string[]>
Get all owners for given paths and group by filename patterns.
Classes
Interfaces
Type aliases
GroupAttributes
ฦฌ GroupAttributes: Record
<string
, ValueType
>
Defined in
packages/pvm-cowners/lib/cowners.ts:8
KvPair
ฦฌ KvPair: [string
, ValueType
]
Defined in
packages/pvm-cowners/lib/kvpairs.ts:2
ValueType
ฦฌ ValueType: boolean
| string
| number
| null
Defined in
packages/pvm-cowners/lib/kvpairs.ts:1
Functions
parseCodeOwners
โธ parseCodeOwners(codeOwners
): OwnersGroup
[]
Parameters
Name | Type |
---|---|
codeOwners | string |
Returns
Defined in
packages/pvm-cowners/lib/cowners.ts:54
parseKvPairs
โธ parseKvPairs(input
): IterableIterator
<KvPair
>
Parameters
Name | Type |
---|---|
input | string |
Returns
IterableIterator
<KvPair
>
Defined in
packages/pvm-cowners/lib/kvpairs.ts:153
parseOwnersLine
โธ parseOwnersLine(codeOwnerLine
, hashbangComments?
): OwnersGroup
Parameters
Name | Type | Default value |
---|---|---|
codeOwnerLine | string | undefined |
hashbangComments | string [] | [] |
Returns
Defined in
packages/pvm-cowners/lib/cowners.ts:36
readCodeOwners
โธ readCodeOwners(cwd?
): Promise
<CodeOwners
| null
>
Parameters
Name | Type |
---|---|
cwd | string |
Returns
Promise
<CodeOwners
| null
>
Defined in
packages/pvm-cowners/lib/cowners.ts:195
reverseIterator
โธ reverseIterator<T
>(items
): IterableIterator
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
items | T [] |
Returns
IterableIterator
<T
>
Defined in
packages/pvm-cowners/lib/iter.ts:2
selectWithPassion
โธ selectWithPassion<T
>(items
, sample
, howMany
): T
[]
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
items | Iterable <T > |
sample | Iterable <T > |
howMany | number |
Returns
T
[]