pub trait GitRepo: Send {
Show 16 methods
// Required methods
fn workdir(&self) -> &Path;
fn current_branch(&self) -> Result<String, GitError>;
fn head_commit_id(&self) -> Result<String, GitError>;
fn create_and_checkout_branch(&self, name: &str) -> Result<(), GitError>;
fn checkout_branch(&self, name: &str) -> Result<(), GitError>;
fn branch_exists(&self, name: &str) -> bool;
fn remote_branch_exists(&self, name: &str, remote: &str) -> bool;
fn delete_branch(&self, name: &str, force: bool) -> Result<(), GitError>;
fn list_local_branches(&self) -> Result<Vec<String>, GitError>;
fn fetch(&self, remote: &str) -> Result<(), GitError>;
fn pull(&self, remote: &str) -> Result<(), GitError>;
fn push(
&self,
branch: &str,
remote: &str,
set_upstream: bool,
) -> Result<(), GitError>;
fn get_remote_url(&self, remote: &str) -> Result<Option<String>, GitError>;
fn status(&self) -> Result<RepoStatusInfo, GitError>;
fn reset_hard(&self, target: &str) -> Result<(), GitError>;
fn safe_pull(
&self,
default_branch: &str,
remote: &str,
) -> Result<SafePullResult, GitError>;
}Expand description
Operations on an already-opened repository.
Required Methods§
Sourcefn current_branch(&self) -> Result<String, GitError>
fn current_branch(&self) -> Result<String, GitError>
Current branch name (or detached HEAD description).
Sourcefn head_commit_id(&self) -> Result<String, GitError>
fn head_commit_id(&self) -> Result<String, GitError>
SHA of the HEAD commit.
Sourcefn create_and_checkout_branch(&self, name: &str) -> Result<(), GitError>
fn create_and_checkout_branch(&self, name: &str) -> Result<(), GitError>
Create a new branch and check it out.
Sourcefn branch_exists(&self, name: &str) -> bool
fn branch_exists(&self, name: &str) -> bool
Does a local branch with this name exist?
Sourcefn remote_branch_exists(&self, name: &str, remote: &str) -> bool
fn remote_branch_exists(&self, name: &str, remote: &str) -> bool
Does a remote-tracking branch exist?
Sourcefn delete_branch(&self, name: &str, force: bool) -> Result<(), GitError>
fn delete_branch(&self, name: &str, force: bool) -> Result<(), GitError>
Delete a local branch.
Sourcefn push(
&self,
branch: &str,
remote: &str,
set_upstream: bool,
) -> Result<(), GitError>
fn push( &self, branch: &str, remote: &str, set_upstream: bool, ) -> Result<(), GitError>
Push a branch to a remote.
Sourcefn get_remote_url(&self, remote: &str) -> Result<Option<String>, GitError>
fn get_remote_url(&self, remote: &str) -> Result<Option<String>, GitError>
Get the URL configured for a remote.
Sourcefn status(&self) -> Result<RepoStatusInfo, GitError>
fn status(&self) -> Result<RepoStatusInfo, GitError>
Porcelain status (staged, modified, untracked, ahead/behind).