Introduction
editMeziantou.Framework.CodeOwners parses CODEOWNERS files, the files of GitHub and GitLab repositories that say who owns which files. Use it to build tools on top of the ownership rules of a repository: find the owners of the files of a pull request, list the files nobody owns, check that every owner is a known user, or request reviewers from your own automation.
What you can do with it
- Parse a file and read its entries, in the order of the file. See Getting started.
- Read the patterns and the owners of each entry: usernames, teams, email addresses and GitLab roles. See Entries and owners.
- Find the owners of a path, with the matching rules of GitHub or GitLab. See Matching paths.
- Read the GitLab sections, with their default owners, their required number of reviewers and whether they are optional. See GitLab sections.
- Know why a file is invalid, with the line and the position of the error. See Handling errors.
Principles
- The dialect is explicit. GitHub and GitLab do not accept the same syntax, so every parse takes a CodeOwnersDialect. See Choose the dialect.
- A file is valid or it is not. Parsing stops at the first error: you get the error, never a partially parsed file.
- Values are copied out of the content. A parsed file does not reference the string or the span it was parsed from.
- Read-only. The entries, the owners and the sections cannot be modified.
- Matching follows the host. GitHub and GitLab do not read the same pattern the same way, so a path is matched with the rules of the dialect of the file. See Matching paths.
Namespace
All the types are in the Meziantou.Framework.CodeOwners namespace:
| Type | Contains |
|---|---|
| CodeOwnersFile | Parse, TryParse, the Entries of a file, and the owners of a path: GetOwners, FindEntries |
| CodeOwnersDialect | GitHub or GitLab |
| CodeOwnersEntry | A pattern, its owners and its section, and whether the pattern matches a path (IsMatch) |
| CodeOwner | An owner and its CodeOwnerType |
| CodeOwnersSection | A GitLab section |
| CodeOwnersParseError, CodeOwnersParseErrorKind, CodeOwnersParseException | Why and where a file is invalid |
Next steps
- Getting started: install the package and parse your first file.