pub struct PlanFingerprint {
pub repository: String,
pub worktree: String,
pub head: String,
pub changes: String,
}Expand description
What a plan was derived from.
Compared, never trusted: a plan whose fingerprint differs from the tree in front of it describes a tree that no longer exists.
use majordomus_cli::commit::{PlanFingerprint, WorkingTreeState};
let f = PlanFingerprint::of("/repo/.git", "/repo", &WorkingTreeState::default());
assert_eq!(f.head, "unborn", "a repository with no commits says so");Fields§
§repository: StringThe repository: git’s common directory, which every worktree of one repository shares and no two repositories do.
worktree: StringThe worktree: this checkout’s own path. Two worktrees of one repository have the same repository and different worktrees, which is what keeps their plans apart.
head: StringHEAD when the plan was derived, or unborn.
changes: StringSHA-256 over every change, its stage and its status, in order. Restaging one file changes it; touching a file the plan does not contain does not.
Implementations§
Source§impl PlanFingerprint
impl PlanFingerprint
Sourcepub fn of(
repository: &str,
worktree: &str,
tree: &WorkingTreeState,
) -> PlanFingerprint
pub fn of( repository: &str, worktree: &str, tree: &WorkingTreeState, ) -> PlanFingerprint
The fingerprint of a tree as it stands.
use majordomus_cli::commit::{PlanFingerprint, WorkingTreeState};
let a = PlanFingerprint::of("/r/.git", "/r", &WorkingTreeState::default());
let b = PlanFingerprint::of("/r/.git", "/r", &WorkingTreeState::default());
assert_eq!(a, b, "deterministic over one tree");Sourcepub fn differs_from(&self, now: &PlanFingerprint) -> Option<String>
pub fn differs_from(&self, now: &PlanFingerprint) -> Option<String>
Why this fingerprint does not describe now, or None when it does.
A sentence rather than a boolean, because “the plan is stale” is not an answer anybody can act on and “HEAD moved from a1b2c3d to e4f5a6b” is.
use majordomus_cli::commit::{PlanFingerprint, WorkingTreeState};
let mut then = WorkingTreeState::default();
then.head = Some("a1b2c3d4e5f6".into());
let mut now = then.clone();
now.head = Some("ffffffffffff".into());
let why = PlanFingerprint::of("/r/.git", "/r", &then)
.differs_from(&PlanFingerprint::of("/r/.git", "/r", &now))
.expect("HEAD moved");
// a sentence, because "the plan is stale" is not something anybody can act on
assert!(why.contains("HEAD moved"), "{why}");Trait Implementations§
Source§impl Clone for PlanFingerprint
impl Clone for PlanFingerprint
Source§fn clone(&self) -> PlanFingerprint
fn clone(&self) -> PlanFingerprint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PlanFingerprint
impl Debug for PlanFingerprint
Source§impl<'de> Deserialize<'de> for PlanFingerprint
impl<'de> Deserialize<'de> for PlanFingerprint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for PlanFingerprint
Source§impl JsonSchema for PlanFingerprint
impl JsonSchema for PlanFingerprint
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for PlanFingerprint
impl PartialEq for PlanFingerprint
Source§fn eq(&self, other: &PlanFingerprint) -> bool
fn eq(&self, other: &PlanFingerprint) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for PlanFingerprint
impl Serialize for PlanFingerprint
impl StructuralPartialEq for PlanFingerprint
Auto Trait Implementations§
impl Freeze for PlanFingerprint
impl RefUnwindSafe for PlanFingerprint
impl Send for PlanFingerprint
impl Sync for PlanFingerprint
impl Unpin for PlanFingerprint
impl UnsafeUnpin for PlanFingerprint
impl UnwindSafe for PlanFingerprint
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<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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.