Skip to main content

GitRepo

Trait GitRepo 

Source
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§

Source

fn workdir(&self) -> &Path

Filesystem path of the working directory.

Source

fn current_branch(&self) -> Result<String, GitError>

Current branch name (or detached HEAD description).

Source

fn head_commit_id(&self) -> Result<String, GitError>

SHA of the HEAD commit.

Source

fn create_and_checkout_branch(&self, name: &str) -> Result<(), GitError>

Create a new branch and check it out.

Source

fn checkout_branch(&self, name: &str) -> Result<(), GitError>

Check out an existing branch.

Source

fn branch_exists(&self, name: &str) -> bool

Does a local branch with this name exist?

Source

fn remote_branch_exists(&self, name: &str, remote: &str) -> bool

Does a remote-tracking branch exist?

Source

fn delete_branch(&self, name: &str, force: bool) -> Result<(), GitError>

Delete a local branch.

Source

fn list_local_branches(&self) -> Result<Vec<String>, GitError>

List local branch names.

Source

fn fetch(&self, remote: &str) -> Result<(), GitError>

Fetch from a remote.

Source

fn pull(&self, remote: &str) -> Result<(), GitError>

Pull (merge mode).

Source

fn push( &self, branch: &str, remote: &str, set_upstream: bool, ) -> Result<(), GitError>

Push a branch to a remote.

Source

fn get_remote_url(&self, remote: &str) -> Result<Option<String>, GitError>

Get the URL configured for a remote.

Source

fn status(&self) -> Result<RepoStatusInfo, GitError>

Porcelain status (staged, modified, untracked, ahead/behind).

Source

fn reset_hard(&self, target: &str) -> Result<(), GitError>

Hard-reset to a ref.

Source

fn safe_pull( &self, default_branch: &str, remote: &str, ) -> Result<SafePullResult, GitError>

Safe pull that handles deleted upstream branches.

Implementors§