pub struct GitRepo { /* private fields */ }Implementations§
Source§impl GitRepo
impl GitRepo
pub fn discover() -> Result<Self>
pub fn root(&self) -> &PathBuf
pub fn has_staged_changes(&self) -> Result<bool>
pub fn has_any_changes(&self) -> Result<bool>
pub fn has_head(&self) -> Result<bool>
pub fn reset_head(&self) -> Result<()>
pub fn stage_file(&self, file: &str) -> Result<bool>
pub fn has_staged_after_add(&self) -> Result<bool>
pub fn commit(&self, message: &str) -> Result<()>
pub fn recent_commits(&self, count: usize) -> Result<String>
pub fn diff_cached(&self) -> Result<String>
pub fn diff_cached_stat(&self) -> Result<String>
pub fn diff_head(&self) -> Result<String>
pub fn status_porcelain(&self) -> Result<String>
pub fn untracked_files(&self) -> Result<String>
pub fn show(&self, rev: &str) -> Result<String>
pub fn log_range(&self, base: &str, count: Option<usize>) -> Result<String>
pub fn diff_range(&self, base: &str) -> Result<String>
pub fn current_branch(&self) -> Result<String>
pub fn head_short(&self) -> Result<String>
Sourcepub fn commits_since_last_tag(&self) -> Result<usize>
pub fn commits_since_last_tag(&self) -> Result<usize>
Count commits since the last tag. If no tags exist, counts all commits.
Sourcepub fn log_detailed(&self, count: usize) -> Result<String>
pub fn log_detailed(&self, count: usize) -> Result<String>
Get detailed log of recent commits (SHA, subject, body) oldest first.
pub fn file_statuses(&self) -> Result<HashMap<String, char>>
Sourcepub fn snapshot_working_tree(&self) -> Result<PathBuf>
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 includes:
- A
stashref created viagit stash create(staged + unstaged changes) - An
untracked.tarof untracked files - The list of staged files in
staged.txt - The repo root path in
repo_root(so restore targets the right directory)
Lives completely outside the repo so the agent cannot touch it.
Sourcepub fn restore_snapshot(&self) -> Result<()>
pub fn restore_snapshot(&self) -> Result<()>
Restore working tree from the latest snapshot (best-effort).
Sourcepub fn clear_snapshot(&self)
pub fn clear_snapshot(&self)
Remove the snapshot after a successful operation.
Sourcepub fn snapshot_dir(&self) -> Result<PathBuf>
pub fn snapshot_dir(&self) -> Result<PathBuf>
Returns the snapshot directory path for this repo.
Sourcepub fn has_snapshot(&self) -> bool
pub fn has_snapshot(&self) -> bool
Check if a valid snapshot exists.
Auto Trait Implementations§
impl Freeze for GitRepo
impl RefUnwindSafe for GitRepo
impl Send for GitRepo
impl Sync for GitRepo
impl Unpin for GitRepo
impl UnsafeUnpin for GitRepo
impl UnwindSafe for GitRepo
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