pub enum Presented {
WorkingTree,
#[non_exhaustive] Commit {
commit: String,
tree: TreeState,
},
}Expand description
The revision a verdict is about.
Every verdict is a verdict at something, and saying which is half of the answer. The working tree is what a person at a terminal is looking at; the checked-out commit judged as committed is the reading a site built from that commit needs.
use majordomus_cli::evidence::freshness::Presented;
// the default of every existing reader: the checkout, with whatever it carries
let here = Presented::WorkingTree;
assert_eq!(here.commit(), None);Variants§
WorkingTree
The reader’s checkout: HEAD plus every tracked, staged and untracked change in it.
#[non_exhaustive]Commit
The checked-out commit, judged as committed: its own ledger, its own tree. Only
presented_commit builds one, because only it checks that the commit is the one
checked out and measures the tree.
Fields
This variant is marked as non-exhaustive
Implementations§
Source§impl Presented
impl Presented
Sourcepub fn commit(&self) -> Option<&str>
pub fn commit(&self) -> Option<&str>
The presented commit, when a commit rather than the working tree is presented.
use majordomus_cli::evidence::freshness::{presented_commit, Presented};
use std::process::Command;
let dir = tempfile::tempdir().unwrap();
let git = |args: &[&str]| {
let out = Command::new("git").arg("-C").arg(dir.path()).args(args).output().unwrap();
String::from_utf8_lossy(&out.stdout).trim().to_string()
};
git(&["init", "-q"]);
git(&["config", "user.email", "t@example.com"]);
git(&["config", "user.name", "t"]);
git(&["commit", "-q", "--allow-empty", "-m", "one"]);
let p = presented_commit(dir.path(), "HEAD", None).unwrap();
assert_eq!(p.commit(), Some(git(&["rev-parse", "HEAD"]).as_str()));
assert_eq!(Presented::WorkingTree.commit(), None);Sourcepub fn tree(&self) -> TreeState
pub fn tree(&self) -> TreeState
The presented tree as the truth table reads it: TreeState::Clean for the working
tree, whose changes are already in the diff, and the measured tree for a commit.
use majordomus_cli::evidence::freshness::{Presented, TreeState};
assert_eq!(Presented::WorkingTree.tree(), TreeState::Clean);Trait Implementations§
impl Eq for Presented
impl StructuralPartialEq for Presented
Auto Trait Implementations§
impl Freeze for Presented
impl RefUnwindSafe for Presented
impl Send for Presented
impl Sync for Presented
impl Unpin for Presented
impl UnsafeUnpin for Presented
impl UnwindSafe for Presented
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.