pub fn locate<P>(ctx: P) -> Option<PathBuf>
where
    P: AsRef<Path>,
{
    let root = ctx.as_ref().join(CODEOWNERS);
    let github = ctx.as_ref().join(".github").join(CODEOWNERS);
    let docs = ctx.as_ref().join("docs").join(CODEOWNERS);
    if root.exists() {
        Some(root)
    } else if github.exists() {
        Some(github)
    } else if docs.exists() {
        Some(docs)
    } else {
        None
    }
}
/// Attempts to locate CODEOWNERS file based on common locations relative to
/// a given git repo
///
/// # Examples
///
/// ```rust
///  match codeowners::locate(".") {
///   Some(ownersfile)  => {
///     println!(
///      "{:#?}",
///      codeowners::from_path(ownersfile)
///    )
///  },
///   _ => println!("failed to find CODEOWNERS file")
/// }
/// ```
Attempts to locate CODEOWNERS file based on common locations relative to
a given git repo
Attempts to locate CODEOWNERS file based on common locations relative to a given git repo
pub fn locate<P>(ctx: P) -> Option<PathBuf>
where
    P: AsRef<Path>,
{
    let root = ctx.as_ref().join(CODEOWNERS);
    let github = ctx.as_ref().join(".github").join(CODEOWNERS);
    let docs = ctx.as_ref().join("docs").join(CODEOWNERS);
    if root.exists() {
        Some(root)
    } else if github.exists() {
        Some(github)
    } else if docs.exists() {
        Some(docs)
    } else {
        None
    }
}
pub fn locate < P > ( ctx : P ) -> Option < PathBuf > where P : AsRef < Path > , { let root = ctx . as_ref ( ) . join ( CODEOWNERS ) ; let github = ctx . as_ref ( ) . join ( " " ) . join ( CODEOWNERS ) ; let docs = ctx . as_ref ( ) . join ( " " ) . join ( CODEOWNERS ) ; if root . exists ( ) { Some ( root ) } else if github . exists ( ) { Some ( github ) } else if docs . exists ( ) { Some ( docs ) } else { None } }
Attempts to locate CODEOWNERS file based on common locations relative to
a given git repo
Attempts to locate CODEOWNERS file based on common locations relative to a given git repo
ctx
P
ctx
P
examples
```rust
match codeowners::locate(".") {
Some(ownersfile)  => {
println!(
"{:#?}",
codeowners::from_path(ownersfile)
)
},
_ => println!("failed to find CODEOWNERS file")
}
```
` ` ` rust match codeowners :: locate ( " . " ) { Some ( ownersfile ) = > { println! ( " { : #? } " codeowners :: from_path ( ownersfile ) ) } _ = > println! ( " failed to find CODEOWNERS file " ) } ` ` `