Struct rustygit::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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.