View Source Codeowners (Codeowners v0.1.2)
A pure Elixir parser for the Github CODEOWNERS specification.
Summary
Functions
Builds a Codeowners
struct from a string containing CODEOWNERS rules.
Loads a CODEOWNERS file from the given path, returning a Codeowners
struct.
Given a Codeowners
struct and an Elixir module, return the matching rule or empty rule.
Given a Codeowners
struct and path, return the matching rule or empty rule.
Types
@type t() :: %Codeowners{ path: String.t(), root: String.t(), rules: Codeowners.Rule.t() }
Functions
Builds a Codeowners
struct from a string containing CODEOWNERS rules.
Parses each line generating a list of Codeowners.Rule
.
Stores File.cwd/0
as :root
.
For most use cases it makes sense to use load/1
, which in turn calls build/1
Loads a CODEOWNERS file from the given path, returning a Codeowners
struct.
load/1
calls build/1
to process the contained ownership rules.
Given a Codeowners
struct and an Elixir module, return the matching rule or empty rule.
Codeowners.rule_for_module
calls Codeowners.rule_for_path
.
Given a Codeowners
struct and path, return the matching rule or empty rule.
Searches in reverse to return the last match. Handles full paths by removing the root directory before matching.