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_fileis set,rootis the repo root. - Subdirectory inside a git repo →
scopeis set relative toroot. - Git repo root →
rootis the repo root, no scope. - Plain directory or file outside git →
is_gitisfalse.
§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);