Skip to main content

RepoBackend

Trait RepoBackend 

Source
pub trait RepoBackend {
Show 14 methods // Required methods fn path(&self) -> &str; fn commits(&self) -> &[CommitInfo]; fn changed_files(&self, index: usize) -> Vec<FileChange>; fn commit_diff(&self, index: usize) -> Diff; fn file_diff(&self, index: usize, path: &str) -> Diff; fn working_status(&self, amend: bool) -> WorkingStatus; fn working_diff(&self, path: &str, staged: bool, amend: bool) -> Diff; fn stage(&self, path: &str) -> Result<(), String>; fn unstage(&self, path: &str, amend: bool) -> Result<(), String>; fn revert(&self, path: &str) -> Result<(), String>; fn delete_untracked(&self, path: &str) -> Result<(), String>; fn commit(&self, message: &str, amend: bool) -> Result<(), String>; fn head_message(&self) -> Option<String>; // Provided method fn signature(&self) -> Option<(String, String)> { ... }
}
Expand description

The interface the UI layer depends on. Implemented by the live Git2Backend and the in-memory FixtureBackend.

Required Methods§

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.

When amend is set the staged side is computed against HEAD’s parent instead of HEAD, so the changes already in the last commit show up as staged (they will be part of the amended commit) and can be unstaged to drop them — exactly how git gui’s amend mode behaves.

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.

Provided Methods§

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§