pub fn resolve(
root: &Path,
declared_value: Option<&str>,
) -> Result<MeshRepositoryIdentity, MeshError>Expand description
Resolve the mesh identity of the repository at root: the declared value when there
is one; otherwise its root commits, refusing a shallow clone (whose “root” is only
where its history was cut) and a repository with no commit yet.
The declaration is consulted first and answers on its own, so a caller that has one never runs git — which is what lets a shallow clone, a worktree of one, or a directory that is not a repository at all still take part in a mesh.
use majordomus_cli::mesh::repository::{declared, resolve};
let nowhere = tempfile::tempdir().unwrap();
let stated = resolve(nowhere.path(), Some("majordomus")).unwrap();
assert_eq!(stated.id, declared("majordomus").unwrap().id, "git was never asked");
// without one, the history has to answer, and a directory holding no history cannot
assert!(resolve(nowhere.path(), None).is_err());