A pure Elixir parser for the GitHub CODEOWNERS specification.
The package can be installed by adding codeowners
to your list of dependencies in mix.exs
:
def deps do
[
{:codeowners, "~> 0.2.0"}
]
end
> codeowners = Codeowners.load(".github/CODEOWNERS")
%Codeowners{
path: "/Users/me/project/.github/CODEOWNERS",
root: "/Users/me/project",
rules: [
%Codeowners.Rule{
pattern: "*",
regex: ~r/[^\/]*/,
owners: ["@global-owner1", "@global-owner2"]
},
%Codeowners.Rule{
pattern: "*.js",
regex: ~r/[^\/]*\.js/,
owners: ["@js-owner"]
},
...
]
}
> matching_rule = Codeowners.rule_for_path(codeowners, "docs/setup.md")
%Codeowners.Rule{
pattern: "docs/*",
regex: ~r/docs\/[^\/]*\z/,
owners: ["docs@example.com"]
}
~/my_project/:$ mix codeowners README.md
Using .github/CODEOWNERS
README.md @my-team
MIT License - see the LICENSE file.