Skip to main content

verify_repo

Function verify_repo 

Source
pub async fn verify_repo(path: &Path) -> Result<RepoInfo>
Expand description

Resolves a user-supplied path into a RepoInfo.

Handles four cases:

  • File inside a git repo → single_file is set, root is the repo root.
  • Subdirectory inside a git repo → scope is set relative to root.
  • Git repo root → root is the repo root, no scope.
  • Plain directory or file outside git → is_git is false.

§Errors

Returns an error if the path does not exist.

§Examples

use gitprint::git::verify_repo;
use std::path::Path;

let info = verify_repo(Path::new(".")).await.unwrap();
println!("repo root: {}", info.root.display());
println!("is git: {}", info.is_git);