pub struct CodeOwners { /* private fields */ }Expand description
Parsed CODEOWNERS file for ownership lookup.
Implementations§
Source§impl CodeOwners
impl CodeOwners
Sourcepub fn from_file(path: &Path) -> Result<Self, String>
pub fn from_file(path: &Path) -> Result<Self, String>
Load and parse a CODEOWNERS file from the given path.
Sourcepub fn discover(root: &Path) -> Result<Self, String>
pub fn discover(root: &Path) -> Result<Self, String>
Auto-probe standard CODEOWNERS locations relative to the project root.
Tries CODEOWNERS, .github/CODEOWNERS, .gitlab/CODEOWNERS, docs/CODEOWNERS.
Sourcepub fn load(root: &Path, config_path: Option<&str>) -> Result<Self, String>
pub fn load(root: &Path, config_path: Option<&str>) -> Result<Self, String>
Load from a config-specified path, or auto-discover.
Sourcepub fn parse(content: &str) -> Result<Self, String>
pub fn parse(content: &str) -> Result<Self, String>
Parse CODEOWNERS content into a lookup structure.
The parser ignores a UTF-8 byte order mark at the start of the content.
Sourcepub fn match_path(&self, relative_path: &Path) -> Option<RuleMatch<'_>>
pub fn match_path(&self, relative_path: &Path) -> Option<RuleMatch<'_>>
Look up the last CODEOWNERS rule that matches a path (relative to the project root).
Returns None when no rule matches. For a GitLab exclusion (!path)
the result has owner: None and owner_count: 0. For a rule before the
first section header the result has section: None and no section
owners.
Sourcepub fn owner_of(&self, relative_path: &Path) -> Option<&str>
pub fn owner_of(&self, relative_path: &Path) -> Option<&str>
Look up the primary owner of a file path (relative to project root).
Returns the first owner from the last matching CODEOWNERS rule,
or None if no rule matches or the last matching rule is a
GitLab-style exclusion (!path).
Sourcepub fn owner_count_of(&self, relative_path: &Path) -> Option<u32>
pub fn owner_count_of(&self, relative_path: &Path) -> Option<u32>
Look up the number of owners matched by the last matching CODEOWNERS rule.
Returns Some(0) when the path is explicitly unowned by a GitLab
negation, and None when no CODEOWNERS rule matches.
Sourcepub fn has_sections(&self) -> bool
pub fn has_sections(&self) -> bool
Whether the parsed file contains at least one GitLab section header.
--group-by section errors out when this is false, since every file
would collapse into the (no section) bucket.
Trait Implementations§
Auto Trait Implementations§
impl Forget for CodeOwners
impl Freeze for CodeOwners
impl Move for CodeOwners
impl RefUnwindSafe for CodeOwners
impl Send for CodeOwners
impl Sync for CodeOwners
impl Unpin for CodeOwners
impl UnsafeUnpin for CodeOwners
impl UnwindSafe for CodeOwners
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more