Struct Repository

Source
pub struct Repository { /* private fields */ }
Expand description

A local git repository

Implementations§

Source§

impl Repository

Source

pub fn new<P: AsRef<Path>>(p: P) -> Repository

Create a Repository struct from a pre-existing local git repository

Source

pub fn clone<P: AsRef<Path>>(url: GitUrl, p: P) -> Result<Repository>

Clone a remote git repository locally

Source

pub fn init<P: AsRef<Path>>(p: P) -> Result<Repository>

Initialise a given folder as a git repository

Source

pub fn create_local_branch(&self, branch_name: &BranchName) -> Result<()>

Create and checkout a new local branch

Source

pub fn switch_branch(&self, branch_name: &BranchName) -> Result<()>

Checkout the specified branch

Source

pub fn add(&self, pathspecs: Vec<&str>) -> Result<()>

Add file contents to the index

Source

pub fn remove(&self, pathspecs: Vec<&str>, force: bool) -> Result<()>

Remove file contents from the index

Source

pub fn commit_all(&self, message: &str) -> Result<()>

Commit all staged files

Source

pub fn push(&self) -> Result<()>

Push the curent branch to its associated remote

Source

pub fn push_to_upstream( &self, upstream: &str, upstream_branch: &BranchName, ) -> Result<()>

Push the curent branch to its associated remote, specifying the upstream branch

Source

pub fn add_remote(&self, name: &str, url: &GitUrl) -> Result<()>

Add a new remote

Source

pub fn fetch_remote(&self, remote: &str) -> Result<()>

Fetch a remote

Source

pub fn create_branch_from_startpoint( &self, branch_name: &BranchName, startpoint: &str, ) -> Result<()>

Create a new branch from a start point, such as another local or remote branch

Source

pub fn list_branches(&self) -> Result<Vec<String>>

List local branches

Source

pub fn list_added(&self) -> Result<Vec<String>>

List files added to staging area

Source

pub fn list_modified(&self) -> Result<Vec<String>>

List all modified files

Source

pub fn list_untracked(&self) -> Result<Vec<String>>

List all untracked files

Source

pub fn list_tracked(&self) -> Result<Vec<String>>

List tracked files

Source

pub fn show_remote_uri(&self, remote_name: &str) -> Result<String>

List all the remote URI for name

Source

pub fn list_remotes(&self) -> Result<Vec<String>>

List all the remote URI for name

Source

pub fn get_hash(&self, short: bool) -> Result<String>

Obtains commit hash of the current HEAD.

Source

pub fn cmd<I, S>(&self, args: I) -> Result<()>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Execute user defined command

Source

pub fn cmd_out<I, S>(&self, args: I) -> Result<Vec<String>>
where I: IntoIterator<Item = S>, S: AsRef<OsStr>,

Execute user defined command and return its output

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.