Skip to main content

StartPoint

Enum StartPoint 

Source
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.

Fields

§reference: String

The ref.

§

RemoteTrunk

The trunk on its remote, fetched by this command.

Fields

§remote: String

The remote.

§branch: String

The trunk branch.

§

RemoteBranch

The branch already on the remote: the local branch is created at it and tracks it.

Fields

§remote: String

The remote.

§branch: String

The branch, the same name on both sides.

§fetched: bool

Whether it was fetched now; false is the remote-tracking ref as last fetched, because the remote could not be read.

§

LocalTrunk

The local trunk: the trunk has no remote, or its remote could not be read.

Fields

§branch: String

The trunk branch.

§unreachable: Option<String>

The remote that could not be read; None when the trunk has no remote.

§reason: Option<String>

Why it could not be read.

§behind: Option<u64>

How many commits the remote’s trunk, as last fetched, has that the local trunk lacks; None when it was never fetched.

§

Head

HEAD, because no trunk is known.

Implementations§

Source§

impl StartPoint

Source

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");
Source

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

Source§

fn clone(&self) -> StartPoint

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StartPoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for StartPoint

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for StartPoint

Source§

impl JsonSchema for StartPoint

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for StartPoint

Source§

fn eq(&self, other: &StartPoint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for StartPoint

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for StartPoint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more