pub struct FixtureBackend { /* private fields */ }Implementations§
Source§impl FixtureBackend
impl FixtureBackend
pub fn new(path: impl Into<String>) -> Self
Sourcepub fn with_signature(self, signature: Option<(String, String)>) -> Self
pub fn with_signature(self, signature: Option<(String, String)>) -> Self
Override the simulated commit identity (or clear it with None).
Sourcepub fn add_commit(
&mut self,
info: CommitInfo,
files: Vec<FileEntry>,
) -> &mut Self
pub fn add_commit( &mut self, info: CommitInfo, files: Vec<FileEntry>, ) -> &mut Self
Append a commit and the files it touched.
Sourcepub fn add_working(
&mut self,
path: &str,
status: ChangeStatus,
staged: bool,
diff_lines: &[(DiffLineKind, &str)],
) -> &mut Self
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).
Sourcepub fn last_commit(&self) -> Option<(String, bool)>
pub fn last_commit(&self) -> Option<(String, bool)>
The most recent commit recorded via RepoBackend::commit, as
(message, amend) — exposed for tests.
Trait Implementations§
Source§impl RepoBackend for FixtureBackend
impl RepoBackend for FixtureBackend
Source§fn commits(&self) -> &[CommitInfo]
fn commits(&self) -> &[CommitInfo]
All commits, newest first (reverse-topological, like
git log).Source§fn changed_files(&self, index: usize) -> Vec<FileChange>
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
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
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
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
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>
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>
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>
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>
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>
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>
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.Auto Trait Implementations§
impl !Freeze for FixtureBackend
impl !RefUnwindSafe for FixtureBackend
impl !Sync for FixtureBackend
impl Send for FixtureBackend
impl Unpin for FixtureBackend
impl UnsafeUnpin for FixtureBackend
impl UnwindSafe for FixtureBackend
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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.