pub struct Codeowners {
pub platform: Option<Platform>,
pub path: Option<String>,
pub header: Option<String>,
pub default_owners: Option<Vec<String>>,
pub rules: Vec<Rule>,
}Expand description
CODEOWNERS file configuration and generator.
Use Codeowners::builder() to create a new instance.
§Example
use cuenv_codeowners::{Codeowners, Platform, Rule};
let codeowners = Codeowners::builder()
.platform(Platform::Github)
.header("Custom header comment")
.default_owners(["@org/maintainers"])
.rule(Rule::new("*.rs", ["@rust-team"]))
.build();
println!("{}", codeowners.generate());Fields§
§platform: Option<Platform>Target platform for the CODEOWNERS file.
path: Option<String>Custom output path override.
header: Option<String>Custom header comment for the file.
default_owners: Option<Vec<String>>Default owners applied to all files (* rule).
rules: Vec<Rule>Ownership rules.
Implementations§
Source§impl Codeowners
impl Codeowners
Sourcepub fn builder() -> CodeownersBuilder
pub fn builder() -> CodeownersBuilder
Create a new builder for constructing a Codeowners configuration.
§Example
use cuenv_codeowners::Codeowners;
let codeowners = Codeowners::builder()
.rule(cuenv_codeowners::Rule::new("*", ["@fallback-team"]))
.build();Sourcepub fn generate(&self) -> String
pub fn generate(&self) -> String
Generate the CODEOWNERS file content.
§Example
use cuenv_codeowners::{Codeowners, Rule};
let codeowners = Codeowners::builder()
.rule(Rule::new("*.rs", ["@rust-team"]))
.build();
let content = codeowners.generate();
assert!(content.contains("*.rs @rust-team"));Sourcepub fn output_path(&self) -> &str
pub fn output_path(&self) -> &str
Get the output path for the CODEOWNERS file.
Returns the custom path if set, otherwise the platform’s default path.
Sourcepub fn detect_platform(repo_root: &Path) -> Platform
pub fn detect_platform(repo_root: &Path) -> Platform
Detect the platform from repository structure.
Checks for platform-specific files/directories:
.github/directory -> GitHub.gitlab-ci.ymlfile -> GitLabbitbucket-pipelines.ymlfile -> Bitbucket- Falls back to GitHub if none detected
§Example
use cuenv_codeowners::{Codeowners, Platform};
use std::path::Path;
let platform = Codeowners::detect_platform(Path::new("."));Trait Implementations§
Source§impl Clone for Codeowners
impl Clone for Codeowners
Source§fn clone(&self) -> Codeowners
fn clone(&self) -> Codeowners
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Codeowners
impl Debug for Codeowners
Source§impl Default for Codeowners
impl Default for Codeowners
Source§fn default() -> Codeowners
fn default() -> Codeowners
Returns the “default value” for a type. Read more
Source§impl PartialEq for Codeowners
impl PartialEq for Codeowners
impl Eq for Codeowners
impl StructuralPartialEq for Codeowners
Auto Trait Implementations§
impl Freeze for Codeowners
impl RefUnwindSafe for Codeowners
impl Send for Codeowners
impl Sync for Codeowners
impl Unpin for Codeowners
impl UnwindSafe for Codeowners
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)