pub fn inputs_digest(
root: &Path,
pathspecs: &[String],
) -> Result<String, String>Expand description
A digest of the tracked files under pathspecs: each file’s path and the SHA-256 of its
content as it is on disk now, in git’s index order. Recorded with every run, and
recomputed on every read, it is what makes evidence current or stale.
use majordomus_cli::economics::inputs_digest;
use std::process::Command;
let dir = tempfile::tempdir().unwrap();
let git = |a: &[&str]| Command::new("git").arg("-C").arg(dir.path()).args(a).output().unwrap();
git(&["init", "-q"]);
std::fs::write(dir.path().join("a.txt"), "one").unwrap();
git(&["add", "-A"]);
let before = inputs_digest(dir.path(), &["a.txt".to_string()]).unwrap();
std::fs::write(dir.path().join("a.txt"), "two").unwrap();
assert_ne!(before, inputs_digest(dir.path(), &["a.txt".to_string()]).unwrap());