Skip to main content

GitDiffSnapshot

Struct GitDiffSnapshot 

Source
pub struct GitDiffSnapshot {
    pub branch: GitBranch,
    pub pushed_sha: Option<String>,
    pub pr_fetched_at: Option<SystemTime>,
    pub default_branch: Option<String>,
    pub repo_gate: RepoGate,
    pub worktree: LayerState<GitDiffStats>,
    pub branch_ahead: LayerState<GitBranchAhead>,
    pub pr: Option<GitPrInfo>,
    pub closes: Vec<GitIssueRef>,
}
Expand description

Snapshot of one project’s git state, suitable for rendering in the Inspector pane’s GIT section. Branch info is folded in here so a single polled scan covers everything the renderer needs.

worktree and branch_ahead are independent: a worker on a topic branch with uncommitted edits surfaces both layers, while the lead on main with a clean tree surfaces neither.

repo_gate makes the repo-vs-scanner-failure states exclusive at the type level. The remaining cross-field invariant the scanner upholds: branch_ahead is only Populated when default_branch resolved (the renderer’s tuple-match relies on it), and the layer states / pr / closes / default_branch stay empty unless repo_gate is RepoGate::InRepo.

Fields§

§branch: GitBranch

Current branch (Named / Detached / NoRepo / Unknown).

§pushed_sha: Option<String>

HEAD’s newest pushed ancestor at scan time: the first sha of HEAD’s first-parent history the remote already tracks. None when nothing is pushed, the walk failed, or the PR lookup was skipped (default branch / detached). The PR cache key rides on this rather than the branch name, so a worktree whose local branch differs from the PR’s head ref still resolves its PR.

§pr_fetched_at: Option<SystemTime>

Wall-clock stamp of the last PR-lookup attempt, Some even when the attempt found nothing or failed - the refetch timer must rate-limit failed lookups too or a persistent gh failure hammers every 10 s scan. None when the PR side never ran (non-repo, default branch, detached).

§default_branch: Option<String>

Resolved default branch (e.g. main, master), if known. None when origin/HEAD is missing AND neither main nor master exists as a local ref.

§repo_gate: RepoGate

Repo gate: in-repo, not-a-repo, or scanner-failed. Replaces the old in_repo + scanner_ok bool pair so the illegal “in a repo but the scanner failed” combination can’t be built.

§worktree: LayerState<GitDiffStats>

Layer 1: uncommitted edits vs HEAD.

§branch_ahead: LayerState<GitBranchAhead>

Layer 2: commits the current branch has ahead of default_branch. The commit count is exposed separately from the file stats because --numstat collapses every commit into a single stat block; the count tells the renderer “this many commits produced these stats”.

§pr: Option<GitPrInfo>

Open pull request containing the current branch’s newest pushed ancestor, if one exists. Only populated for Named non-default branches; None otherwise. Cached across scans while the branch name and pushed sha both hold and the fetch is less than 5 minutes old (see the scanner’s prev parameter).

§closes: Vec<GitIssueRef>

Issues the open PR closes (from GitHub’s closingIssuesReferences). Empty when there’s no PR or the PR doesn’t reference any issues. Cached alongside pr.

Trait Implementations§

Source§

impl Clone for GitDiffSnapshot

Source§

fn clone(&self) -> Self

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 GitDiffSnapshot

Source§

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

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

impl Eq for GitDiffSnapshot

Source§

impl PartialEq for GitDiffSnapshot

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GitDiffSnapshot

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
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
§

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

§

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

Checks if this value is equivalent to the given key. Read more
§

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.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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