pub struct GitRepo { /* private fields */ }
Expand description
Represents a Git repository and provides methods for interacting with it.
Implementations§
Source§impl GitRepo
impl GitRepo
Sourcepub fn new_from_url(repository_url: Option<String>) -> Result<Self>
pub fn new_from_url(repository_url: Option<String>) -> Result<Self>
Sourcepub fn clone_remote_repository(url: &str) -> Result<Self>
pub fn clone_remote_repository(url: &str) -> Result<Self>
Sourcepub fn open_repo(&self) -> Result<Repository, Error>
pub fn open_repo(&self) -> Result<Repository, Error>
Open the repository at the stored path
Sourcepub fn is_remote(&self) -> bool
pub fn is_remote(&self) -> bool
Returns whether this GitRepo
instance is working with a remote repository
Sourcepub fn get_remote_url(&self) -> Option<&str>
pub fn get_remote_url(&self) -> Option<&str>
Returns the original remote URL if this is a cloned repository
Sourcepub fn update_remote(&self) -> Result<()>
pub fn update_remote(&self) -> Result<()>
Updates the remote repository by fetching the latest changes
Sourcepub fn get_current_branch(&self) -> Result<String>
pub fn get_current_branch(&self) -> Result<String>
Retrieves the current branch name.
§Returns
A Result containing the branch name as a String or an error.
Sourcepub fn execute_hook(&self, hook_name: &str) -> Result<()>
pub fn execute_hook(&self, hook_name: &str) -> Result<()>
Sourcepub fn get_repo_root() -> Result<PathBuf>
pub fn get_repo_root() -> Result<PathBuf>
Get the root directory of the current git repository
Sourcepub fn extract_files_info(
&self,
include_unstaged: bool,
) -> Result<RepoFilesInfo>
pub fn extract_files_info( &self, include_unstaged: bool, ) -> Result<RepoFilesInfo>
Extract files info without crossing async boundaries
Sourcepub fn get_unstaged_files(&self) -> Result<Vec<StagedFile>>
pub fn get_unstaged_files(&self) -> Result<Vec<StagedFile>>
Gets unstaged file changes from the repository
Sourcepub async fn get_project_metadata(
&self,
changed_files: &[String],
) -> Result<ProjectMetadata>
pub async fn get_project_metadata( &self, changed_files: &[String], ) -> Result<ProjectMetadata>
Sourcepub async fn get_git_info(&self, _config: &Config) -> Result<CommitContext>
pub async fn get_git_info(&self, _config: &Config) -> Result<CommitContext>
Sourcepub async fn get_git_info_with_unstaged(
&self,
_config: &Config,
include_unstaged: bool,
) -> Result<CommitContext>
pub async fn get_git_info_with_unstaged( &self, _config: &Config, include_unstaged: bool, ) -> Result<CommitContext>
Sourcepub fn get_recent_commits(&self, count: usize) -> Result<Vec<RecentCommit>>
pub fn get_recent_commits(&self, count: usize) -> Result<Vec<RecentCommit>>
Sourcepub fn commit_and_verify(&self, message: &str) -> Result<CommitResult>
pub fn commit_and_verify(&self, message: &str) -> Result<CommitResult>
Sourcepub async fn get_git_info_for_commit(
&self,
_config: &Config,
commit_id: &str,
) -> Result<CommitContext>
pub async fn get_git_info_for_commit( &self, _config: &Config, commit_id: &str, ) -> Result<CommitContext>
Sourcepub fn get_commit_date(&self, commit_ish: &str) -> Result<String>
pub fn get_commit_date(&self, commit_ish: &str) -> Result<String>
Get the commit date for a reference
Sourcepub fn get_commits_between_with_callback<T, F>(
&self,
from: &str,
to: &str,
callback: F,
) -> Result<Vec<T>>
pub fn get_commits_between_with_callback<T, F>( &self, from: &str, to: &str, callback: F, ) -> Result<Vec<T>>
Get commits between two references with a callback
Sourcepub fn commit(&self, message: &str) -> Result<CommitResult>
pub fn commit(&self, message: &str) -> Result<CommitResult>
Commit changes to the repository
Sourcepub fn is_inside_work_tree() -> Result<bool>
pub fn is_inside_work_tree() -> Result<bool>
Check if inside a working tree
Sourcepub fn get_commit_files(&self, commit_id: &str) -> Result<Vec<StagedFile>>
pub fn get_commit_files(&self, commit_id: &str) -> Result<Vec<StagedFile>>
Get the files changed in a specific commit
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
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>
Converts
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>
Converts
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