pub struct GitIdentity {
pub common_dir: PathBuf,
pub id: String,
pub linked: bool,
}Expand description
The git repository a checkout belongs to, as distinct from the checkout itself.
identity names a checkout: one server, one lease, one index per checkout root. Every
linked worktree of one git repository is a checkout of its own by that measure, and
nothing in it said that they belong together. This does: the git directory every work
tree shares (git rev-parse --git-common-dir) is the repository’s identity, its digest
is one value for every checkout of that repository, and linked says whether this
checkout is the primary one or a work tree hanging off it. None where git cannot be
asked: a repository of the layer does not have to be version controlled.
use majordomus_cli::repository::{git_identity, identity, GitIdentity};
use std::process::Command;
let dir = tempfile::tempdir().unwrap();
let root = dir.path().join("repo");
std::fs::create_dir_all(&root).unwrap();
let git = |args: &[&str]| assert!(Command::new("git").arg("-C").arg(&root).args(args).status().unwrap().success());
git(&["init", "-q", "."]);
git(&["-c", "user.email=t@example.com", "-c", "user.name=t", "commit", "-q", "--allow-empty", "-m", "init"]);
let wt = dir.path().join("repo-wt");
git(&["worktree", "add", "-q", "-b", "feature/x", wt.to_str().unwrap()]);
let primary: GitIdentity = git_identity(&root).expect("a work tree");
let linked: GitIdentity = git_identity(&wt).expect("a linked work tree");
assert_eq!(primary.id, linked.id, "one repository");
assert_ne!(identity(&root), identity(&wt), "two checkouts");
assert!(!primary.linked && linked.linked);
assert!(!primary.id.contains('/'), "a digest, never a path");Fields§
§common_dir: PathBufThe git directory every work tree of the repository shares, canonical.
id: StringIts digest: the same for every checkout of one repository, different across repositories, and never a path.
linked: boolWhether this checkout is a linked work tree rather than the primary one.
Trait Implementations§
Source§impl Clone for GitIdentity
impl Clone for GitIdentity
Source§fn clone(&self) -> GitIdentity
fn clone(&self) -> GitIdentity
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 GitIdentity
impl Debug for GitIdentity
Source§impl<'de> Deserialize<'de> for GitIdentity
impl<'de> Deserialize<'de> for GitIdentity
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 GitIdentity
Source§impl JsonSchema for GitIdentity
impl JsonSchema for GitIdentity
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 GitIdentity
impl PartialEq for GitIdentity
Source§fn eq(&self, other: &GitIdentity) -> bool
fn eq(&self, other: &GitIdentity) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for GitIdentity
impl Serialize for GitIdentity
impl StructuralPartialEq for GitIdentity
Auto Trait Implementations§
impl Freeze for GitIdentity
impl RefUnwindSafe for GitIdentity
impl Send for GitIdentity
impl Sync for GitIdentity
impl Unpin for GitIdentity
impl UnsafeUnpin for GitIdentity
impl UnwindSafe for GitIdentity
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.