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
impl Repository
Sourcepub fn new() -> Repository
pub fn new() -> Repository
Get a repository in the current directory.
use mhgit::Repository;
let status = Repository::new()
.status()?;
Sourcepub fn at<P: AsRef<Path>>(path: P) -> Result<Repository, Error>
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()?;
Sourcepub fn gitout(&mut self, val: GitOut) -> &mut Repository
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()?;
Sourcepub fn add(&mut self) -> Result<&mut Self, Error>
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
.
Sourcepub fn commit(&mut self, msg: &str) -> Result<&mut Self, Error>
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
.
Sourcepub fn fetch(&mut self) -> Result<&mut Self, Error>
pub fn fetch(&mut self) -> Result<&mut Self, Error>
Run git fetch
in the repository.
The command is called with –all
Sourcepub fn notes(&mut self, msg: &str) -> Result<&mut Self, Error>
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
.
Sourcepub fn pull(&mut self) -> Result<&mut Self, Error>
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
.
Sourcepub fn push(&mut self) -> Result<&mut Self, Error>
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
.
Sourcepub fn remote(&mut self, name: &str, url: &str) -> Result<&mut Self, Error>
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
.
Sourcepub fn status(&self) -> Result<Status, Error>
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
.
Trait Implementations§
Source§impl Debug for Repository
impl Debug for Repository
Source§impl Default for Repository
impl Default for Repository
Source§fn default() -> Repository
fn default() -> Repository
Source§impl Hash for Repository
impl Hash for Repository
Source§impl PartialEq for Repository
impl PartialEq for Repository
impl Eq for Repository
impl StructuralPartialEq for Repository
Auto Trait Implementations§
impl Freeze for Repository
impl RefUnwindSafe for Repository
impl Send for Repository
impl Sync for Repository
impl Unpin for Repository
impl UnwindSafe for Repository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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