pub struct GitRepo { /* private fields */ }Expand description
A git repository handle providing typed methods for git operations.
All operations shell out to git -C {path} with LC_ALL=C.
Implementations§
Source§impl GitRepo
impl GitRepo
pub fn new(path: impl Into<PathBuf>) -> Self
pub fn path(&self) -> &Path
Sourcepub fn is_git_repo(&self) -> bool
pub fn is_git_repo(&self) -> bool
Check if the path is a git repository (has .git directory or file)
Sourcepub fn default_branch(&self) -> Result<String, GitError>
pub fn default_branch(&self) -> Result<String, GitError>
Get the default branch name (main or master)
Sourcepub fn is_dirty(&self) -> Result<bool, GitError>
pub fn is_dirty(&self) -> Result<bool, GitError>
Check if the working tree has uncommitted changes
Sourcepub fn change_count(&self) -> Result<usize, GitError>
pub fn change_count(&self) -> Result<usize, GitError>
Count the number of changed files (staged + unstaged + untracked).
Sourcepub fn current_branch(&self) -> Result<String, GitError>
pub fn current_branch(&self) -> Result<String, GitError>
Get the current branch name (empty string if detached HEAD)
Sourcepub fn ahead_behind(&self, base: &str) -> Result<(u32, u32), GitError>
pub fn ahead_behind(&self, base: &str) -> Result<(u32, u32), GitError>
Get ahead/behind counts relative to a base branch
Sourcepub fn worktree_add(
&self,
path: &Path,
branch: &str,
base: &str,
) -> Result<(), GitError>
pub fn worktree_add( &self, path: &Path, branch: &str, base: &str, ) -> Result<(), GitError>
Add a new worktree
Sourcepub fn worktree_remove(&self, path: &Path, force: bool) -> Result<(), GitError>
pub fn worktree_remove(&self, path: &Path, force: bool) -> Result<(), GitError>
Remove a worktree
Sourcepub fn worktree_lock(&self, path: &Path, reason: &str) -> Result<(), GitError>
pub fn worktree_lock(&self, path: &Path, reason: &str) -> Result<(), GitError>
Lock a worktree with a reason
Sourcepub fn worktree_prune(&self) -> Result<(), GitError>
pub fn worktree_prune(&self) -> Result<(), GitError>
Prune stale worktree entries
Sourcepub fn worktree_list(&self) -> Result<Vec<WorktreeEntry>, GitError>
pub fn worktree_list(&self) -> Result<Vec<WorktreeEntry>, GitError>
List worktrees using --porcelain format for reliable parsing
Sourcepub fn branch_delete(&self, name: &str, force: bool) -> Result<(), GitError>
pub fn branch_delete(&self, name: &str, force: bool) -> Result<(), GitError>
Delete a local branch
Sourcepub fn ref_exists(&self, refspec: &str) -> Result<bool, GitError>
pub fn ref_exists(&self, refspec: &str) -> Result<bool, GitError>
Check if a ref exists (local branch, remote ref, tag, or arbitrary ref).
Sourcepub fn push_tracking(&self, branch: &str) -> Result<(), GitError>
pub fn push_tracking(&self, branch: &str) -> Result<(), GitError>
Push a branch and set up tracking
Sourcepub fn resolve_start_point(&self, branch: &str) -> String
pub fn resolve_start_point(&self, branch: &str) -> String
Resolve the best available start point for a new worktree.
Prefers origin/{branch} (freshest state), falls back to local {branch}.
Call after fetch() to ensure remote refs are up-to-date.
Sourcepub fn pull_rebase(&self) -> Result<(), GitError>
pub fn pull_rebase(&self) -> Result<(), GitError>
Pull with rebase from origin
Sourcepub fn rebase_abort(&self) -> Result<(), GitError>
pub fn rebase_abort(&self) -> Result<(), GitError>
Abort a rebase in progress
Sourcepub fn reset_hard(&self) -> Result<(), GitError>
pub fn reset_hard(&self) -> Result<(), GitError>
Hard reset to HEAD (discard all staged and unstaged changes)
Sourcepub fn clean_untracked(&self) -> Result<(), GitError>
pub fn clean_untracked(&self) -> Result<(), GitError>
Remove untracked files and directories
Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more