pub enum StartPoint {
Given {
reference: String,
},
RemoteTrunk {
remote: String,
branch: String,
},
RemoteBranch {
remote: String,
branch: String,
fetched: bool,
},
LocalTrunk {
branch: String,
unreachable: Option<String>,
reason: Option<String>,
behind: Option<u64>,
},
Head,
}Expand description
Where a new branch started, and why there.
The local trunk of a long-lived checkout is routinely hundreds of commits behind its remote, because nothing advances it; a branch cut from it carries none of that work and every worker had to reset it by hand. So the default is the remote’s trunk, fetched at the moment of creation, and the local trunk only when the remote cannot be read — said, never silent.
use majordomus_cli::worktree::StartPoint;
let p = StartPoint::RemoteTrunk { remote: "origin".into(), branch: "master".into() };
assert_eq!(p.reference(), "origin/master");
assert!(p.fallback().is_none());
let fell = StartPoint::LocalTrunk {
branch: "master".into(),
unreachable: Some("origin".into()),
reason: Some("no answer within 60s".into()),
behind: Some(779),
};
assert_eq!(fell.reference(), "master");
assert!(fell.fallback().unwrap().contains("779 commits behind origin/master"));Variants§
Given
The ref --base named, as given; never fetched.
RemoteTrunk
The trunk on its remote, fetched by this command.
RemoteBranch
The branch already on the remote: the local branch is created at it and tracks it.
Fields
LocalTrunk
The local trunk: the trunk has no remote, or its remote could not be read.
Fields
Head
HEAD, because no trunk is known.
Implementations§
Source§impl StartPoint
impl StartPoint
Sourcepub fn reference(&self) -> String
pub fn reference(&self) -> String
The ref git is given to start the branch from.
use majordomus_cli::worktree::StartPoint;
let remote = StartPoint::RemoteTrunk { remote: "origin".into(), branch: "master".into() };
assert_eq!(remote.reference(), "origin/master");
assert_eq!(StartPoint::Head.reference(), "HEAD");Sourcepub fn fallback(&self) -> Option<String>
pub fn fallback(&self) -> Option<String>
The sentence a person must read when the start is not the remote’s state as it is
now; None when it is, or when nothing better could have been asked.
use majordomus_cli::worktree::StartPoint;
let stale = StartPoint::LocalTrunk {
branch: "master".into(),
unreachable: Some("origin".into()),
reason: Some("offline".into()),
behind: Some(3),
};
let said = stale.fallback().expect("a stale start is said");
assert!(said.contains("3 commits behind origin/master"), "{said}");
let remote = StartPoint::RemoteTrunk { remote: "origin".into(), branch: "master".into() };
assert_eq!(remote.fallback(), None);Trait Implementations§
Source§impl Clone for StartPoint
impl Clone for StartPoint
Source§fn clone(&self) -> StartPoint
fn clone(&self) -> StartPoint
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 StartPoint
impl Debug for StartPoint
Source§impl<'de> Deserialize<'de> for StartPoint
impl<'de> Deserialize<'de> for StartPoint
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 StartPoint
Source§impl JsonSchema for StartPoint
impl JsonSchema for StartPoint
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 StartPoint
impl PartialEq for StartPoint
Source§fn eq(&self, other: &StartPoint) -> bool
fn eq(&self, other: &StartPoint) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for StartPoint
impl Serialize for StartPoint
impl StructuralPartialEq for StartPoint
Auto Trait Implementations§
impl Freeze for StartPoint
impl RefUnwindSafe for StartPoint
impl Send for StartPoint
impl Sync for StartPoint
impl Unpin for StartPoint
impl UnsafeUnpin for StartPoint
impl UnwindSafe for StartPoint
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.