Skip to main content

FixtureBackend

Struct FixtureBackend 

Source
pub struct FixtureBackend { /* private fields */ }

Implementations§

Source§

impl FixtureBackend

Source

pub fn new(path: impl Into<String>) -> Self

Source

pub fn with_signature(self, signature: Option<(String, String)>) -> Self

Override the simulated commit identity (or clear it with None).

Source

pub fn add_commit( &mut self, info: CommitInfo, files: Vec<FileEntry>, ) -> &mut Self

Append a commit and the files it touched.

Source

pub fn add_working( &mut self, path: &str, status: ChangeStatus, staged: bool, diff_lines: &[(DiffLineKind, &str)], ) -> &mut Self

Add a path to the simulated working tree (for commit-mode tests/demos).

Source

pub fn last_commit(&self) -> Option<(String, bool)>

The most recent commit recorded via RepoBackend::commit, as (message, amend) — exposed for tests.

Source

pub fn sample() -> Self

A small, realistic history used by snapshot tests and as a demo when no real repository is available. Five commits, two refs, varied statuses.

Trait Implementations§

Source§

impl RepoBackend for FixtureBackend

Source§

fn path(&self) -> &str

Human-readable path to the repository (shown in the title bar).
Source§

fn commits(&self) -> &[CommitInfo]

All commits, newest first (reverse-topological, like git log).
Source§

fn changed_files(&self, index: usize) -> Vec<FileChange>

Files changed by the commit at index, against its first parent.
Source§

fn commit_diff(&self, index: usize) -> Diff

Unified diff of the whole commit against its first parent.
Source§

fn file_diff(&self, index: usize, path: &str) -> Diff

Unified diff for a single file within the commit.
Source§

fn working_status(&self, amend: bool) -> WorkingStatus

The current working-tree status: staged and unstaged changes. Read more
Source§

fn working_diff(&self, path: &str, _staged: bool, amend: bool) -> Diff

Diff for a single working-tree path. With staged false this is the working copy against the index (git diff); with staged true it is the index against the staged base — HEAD normally, HEAD’s parent when amend is set.
Source§

fn stage(&self, path: &str) -> Result<(), String>

Stage a path (git add <path>), staging a deletion if the file is gone from the working tree. Returns a human-readable error on failure.
Source§

fn unstage(&self, path: &str, amend: bool) -> Result<(), String>

Unstage a path. Normally resets the index entry to HEAD (git reset HEAD -- <path>); when amend is set it resets to HEAD’s parent, removing the path’s change from the commit being amended.
Source§

fn revert(&self, path: &str) -> Result<(), String>

Revert (discard) the unstaged working-tree changes to path, restoring the working copy from the index — git checkout -- <path>, the destructive half of git gui’s “Revert Changes”. Only the working-vs-index delta is dropped; any staged changes to the same path are preserved. Untracked files have no index entry to restore from; use delete_untracked for those.
Source§

fn delete_untracked(&self, path: &str) -> Result<(), String>

Delete an untracked file from the working tree. This is the “revert” a brand-new file gets: it isn’t in the index or HEAD, so the only way to undo its appearance is to remove it. The content is gone for good — git never had a copy. The caller is responsible for only passing untracked paths.
Source§

fn commit(&self, message: &str, amend: bool) -> Result<(), String>

Commit the staged changes with message. When amend is set, replace the current HEAD commit instead of adding a new one.
Source§

fn head_message(&self) -> Option<String>

The full message of the current HEAD commit, used to pre-fill the editor when amending. None if there is no commit yet.
Source§

fn signature(&self) -> Option<(String, String)>

The configured commit identity as (name, email), used by the commit screen’s “Sign Off” shortcut to append a Signed-off-by trailer. None when no identity is configured.

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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