pub fn resolves(root: &Path, rev: &str) -> boolExpand description
Does rev name a commit this clone has?
git rev-parse --verify --quiet <rev>^{commit}, through read_only: a branch, a tag, a
full or abbreviated object name, HEAD. Forty hex digits that no object has do not
resolve, which is the difference between a well-formed commit id and a commit.
use majordomus_cli::git::resolves;
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"]);
// an unborn repository has no HEAD to name
assert!(!resolves(dir.path(), "HEAD"));
git(&["config", "user.email", "t@example.com"]);
git(&["config", "user.name", "t"]);
git(&["commit", "-q", "--allow-empty", "-m", "one"]);
assert!(resolves(dir.path(), "HEAD"));
assert!(!resolves(dir.path(), &"0".repeat(40)), "well-formed is not the same as present");