Struct Repository

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

A handle to a git repository.

By creating with at the repository may be somewhere other than in current working directory.

use mhgit::Repository;
Repository::at("/home/mh/awesomeness")?
           .init()?
           .add()?
           .commit("Initial commit")?;

Implementations§

Source§

impl Repository

Source

pub fn new() -> Repository

Get a repository in the current directory.

use mhgit::Repository;
let status = Repository::new()
                        .status()?;
Source

pub fn at<P: AsRef<Path>>(path: P) -> Result<Repository, Error>

Get a repository at the given location.

use mhgit::Repository;
Repository::at("/home/mh/awesomeness")?
           .init()?;
Source

pub fn is_init(&self) -> bool

Return true if the repository is initialized.

Source

pub fn gitout(&mut self, val: GitOut) -> &mut Repository

Configure if the output of git commands run in this repo should be piped or printed to screen.

Piping is default.

use mhgit::Repository;
use mhgit::GitOut::Print;
Repository::new()
    .gitout(Print)
    .status()?;
Source

pub fn add(&mut self) -> Result<&mut Self, Error>

Run git add in the repository.

The command is called with the –all option. To call git add with different options use AddOptions.

Source

pub fn commit(&mut self, msg: &str) -> Result<&mut Self, Error>

Run git commit in the repository, with the given commit message.

The command is called with –allow-empty, avoiding errors if no changes were added since last commit. To call git commit with different options use CommitOptions.

Source

pub fn fetch(&mut self) -> Result<&mut Self, Error>

Run git fetch in the repository.

The command is called with –all

Source

pub fn init(&mut self) -> Result<&mut Self, Error>

Run git init, initializing the repository.

Source

pub fn notes(&mut self, msg: &str) -> Result<&mut Self, Error>

Run git notes add, adding a note to HEAD.

To call git notes with different optinos use NotesOptions.

Source

pub fn pull(&mut self) -> Result<&mut Self, Error>

Run git pull without specifying remote or refs.

To call git pull with different options use PullOptions.

Source

pub fn push(&mut self) -> Result<&mut Self, Error>

Run git push without specifying remote or refs.

To call git push with different options use PushOptions.

Source

pub fn remote(&mut self, name: &str, url: &str) -> Result<&mut Self, Error>

Run git remote add in the repository.

This adds a single remote to the repository. To call git remote with different options use RemoteOptions.

Source

pub fn status(&self) -> Result<Status, Error>

Run git status parsing the status into idiomatic Rust type.

The status information is returned in a Status.

Source

pub fn stash(&mut self) -> Result<&mut Self, Error>

Run git stash in the repository.

The command is run without ony options.

Source

pub fn tag(&mut self, tagname: &str) -> Result<&mut Self, Error>

Run git tag, creating a new tag object.

To call git tag with different options use TagOptions.

Trait Implementations§

Source§

impl Debug for Repository

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Repository

Source§

fn default() -> Repository

Returns the “default value” for a type. Read more
Source§

impl Hash for Repository

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Repository

Source§

fn eq(&self, other: &Repository) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Repository

Source§

impl StructuralPartialEq for Repository

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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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.