pub struct GitRepo { /* private fields */ }Expand description
Git repository operations wrapper.
This struct provides a clean API for common git operations,
executing them via std::process::Command internally.
Implementations§
Source§impl GitRepo
impl GitRepo
Sourcepub fn current_branch(&self) -> Result<String>
pub fn current_branch(&self) -> Result<String>
Sourcepub fn detect_default_branch(&self) -> String
pub fn detect_default_branch(&self) -> String
Detect the default branch (main/master) of the repository.
Queries the remote origin to determine the default branch. Falls back to “main” if detection fails.
§Example
use gba_core::git::GitRepo;
let repo = GitRepo::new(".");
let default = repo.detect_default_branch();
println!("Default branch: {}", default);Sourcepub fn create_worktree(&self, path: &Path, branch: &str) -> Result<()>
pub fn create_worktree(&self, path: &Path, branch: &str) -> Result<()>
Create a new worktree with a new branch.
§Arguments
path- Path where the worktree should be createdbranch- Name of the new branch to create
§Errors
Returns an error if the git command fails.
§Example
use std::path::Path;
use gba_core::git::GitRepo;
let repo = GitRepo::new(".");
repo.create_worktree(Path::new(".trees/feature"), "feature/new-feature")?;Sourcepub fn head_short_sha(&self) -> Result<Option<String>>
pub fn head_short_sha(&self) -> Result<Option<String>>
Get the short SHA of HEAD.
Returns None if the repository has no commits yet.
§Errors
Returns an error if the git command fails for reasons other than an empty repository.
§Example
use gba_core::git::GitRepo;
let repo = GitRepo::new(".");
if let Some(sha) = repo.head_short_sha()? {
println!("Current commit: {}", sha);
}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 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