Skip to main content

verify

Function verify 

Source
pub fn verify(dir: &Path, profiles: &Profiles, root: &Path) -> PackVerdict
Expand description

Verify a written pack: every file the manifest names is there with its digest, nothing else is, every block’s content has the digest its marker records, no carried path is a binary, an artifact, a link or a worktree under the profile it names, no file of the pack is over the token budget or holds a NUL byte or a leak, and the pack has no more files than the profile allows. root is the checkout whose path, with the account’s home directory, no file may name. Rebuilding is never the remedy for a finding here: a pack that fails is not sent.

use majordomus_cli::pack::{build, plan, verify, Profiles};
let profiles = Profiles::load(&share, &root).unwrap();
let out = dir.path().join("pack");
build(&plan(&root, &share, None), &root, &out).unwrap();
assert!(verify(&out, &profiles, &root).passes);
// a file dropped into the pack after it was built is a stray
std::fs::write(out.join("99-extra.md"), "extra\n").unwrap();
let v = verify(&out, &profiles, &root);
assert!(v.measured && !v.passes);
assert!(v.findings.iter().any(|f| f.code == "pack.stray"), "{:?}", v.findings);