pub fn working_tree_ignoring(root: &Path, ignore: &[&str]) -> StringExpand description
clean, dirty or unknown as inspect decides it, except that a change to one of
the given repository-relative paths does not make the tree dirty.
One caller needs this: recording a run writes the evidence ledger, so the second
recording in a session would be stamped dirty by its predecessor’s own bookkeeping —
about a tree in which nothing the run measured had changed. “Dirty only because of the
ledger” is not dirty; every other path still is.
use majordomus_cli::git::working_tree_ignoring;
use std::process::Command;
let dir = tempfile::tempdir().unwrap();
let git = |args: &[&str]| {
Command::new("git").arg("-C").arg(dir.path()).args(args).output().unwrap()
};
git(&["init", "-q"]);
git(&["config", "user.email", "t@example.com"]);
git(&["config", "user.name", "t"]);
std::fs::write(dir.path().join("ledger.json"), "{}").unwrap();
std::fs::write(dir.path().join("a.md"), "a").unwrap();
git(&["add", "-A"]);
git(&["commit", "-qm", "init"]);
std::fs::write(dir.path().join("ledger.json"), "{\"v\":1}").unwrap();
assert_eq!(working_tree_ignoring(dir.path(), &["ledger.json"]), "clean");
// anything else is still dirty
std::fs::write(dir.path().join("a.md"), "b").unwrap();
assert_eq!(working_tree_ignoring(dir.path(), &["ledger.json"]), "dirty");