Skip to main content

GitRepo

Struct GitRepo 

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

Implementations§

Source§

impl GitRepo

Source

pub fn discover() -> Result<Self>

Source

pub fn root(&self) -> &PathBuf

Source

pub fn has_staged_changes(&self) -> Result<bool>

Source

pub fn has_any_changes(&self) -> Result<bool>

Source

pub fn has_head(&self) -> Result<bool>

Source

pub fn reset_head(&self) -> Result<()>

Source

pub fn stage_file(&self, file: &str) -> Result<bool>

Source

pub fn has_staged_after_add(&self) -> Result<bool>

Source

pub fn commit(&self, message: &str) -> Result<()>

Source

pub fn recent_commits(&self, count: usize) -> Result<String>

Source

pub fn diff_cached(&self) -> Result<String>

Source

pub fn diff_cached_stat(&self) -> Result<String>

Source

pub fn diff_head(&self) -> Result<String>

Source

pub fn status_porcelain(&self) -> Result<String>

Source

pub fn untracked_files(&self) -> Result<String>

Source

pub fn show(&self, rev: &str) -> Result<String>

Source

pub fn log_range(&self, base: &str, count: Option<usize>) -> Result<String>

Source

pub fn diff_range(&self, base: &str) -> Result<String>

Source

pub fn current_branch(&self) -> Result<String>

Source

pub fn head_short(&self) -> Result<String>

Source

pub fn commits_since_last_tag(&self) -> Result<usize>

Count commits since the last tag. If no tags exist, counts all commits.

Source

pub fn log_detailed(&self, count: usize) -> Result<String>

Get detailed log of recent commits (SHA, subject, body) oldest first.

Source

pub fn file_statuses(&self) -> Result<HashMap<String, char>>

Source

pub fn snapshot_working_tree(&self) -> Result<PathBuf>

Create a snapshot of the working tree state into the platform data directory. Location: <data_local_dir>/sr/snapshots/<repo-hash>/

  • macOS: ~/Library/Application Support/sr/snapshots//
  • Linux: ~/.local/share/sr/snapshots//
  • Windows: %LOCALAPPDATA%/sr/snapshots//

The snapshot directly copies every changed/added/deleted file into files/ alongside a manifest.json that records each file’s status and whether it was staged. This avoids git-stash entirely — restore is a plain file copy that cannot conflict.

Lives completely outside the repo so the agent cannot touch it.

Source

pub fn restore_snapshot(&self) -> Result<()>

Restore working tree from the latest snapshot.

  1. Reset HEAD to the original commit (undoes any partial commits)
  2. Clean the index
  3. Copy every snapshotted file back from files/
  4. Delete files that were deleted at snapshot time
  5. Re-stage files that were staged at snapshot time

This is a plain file copy — no git-stash, no merge conflicts.

Source

pub fn clear_snapshot(&self)

Remove the snapshot after a successful operation.

Source

pub fn snapshot_dir(&self) -> Result<PathBuf>

Returns the snapshot directory path for this repo.

Source

pub fn has_snapshot(&self) -> bool

Check if a valid snapshot exists.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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.