Struct git_cmd::Repo

source ·
pub struct Repo { /* private fields */ }
Expand description

Repository

Implementations§

source§

impl Repo

source

pub fn new(directory: impl AsRef<Path>) -> Result<Self>

Returns an error if the directory doesn’t contain any commit

source

pub fn directory(&self) -> &Path

source

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

Check if there are uncommitted changes.

source

pub fn checkout_new_branch(&self, branch: &str) -> Result<()>

source

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

source

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

source

pub fn add<T: AsRef<str>>(&self, paths: &[T]) -> Result<()>

source

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

source

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

source

pub fn push(&self, obj: &str) -> Result<()>

source

pub fn fetch(&self, obj: &str) -> Result<()>

source

pub fn force_push(&self, obj: &str) -> Result<()>

source

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

source

pub fn original_branch(&self) -> &str

Branch name before running any git operation. I.e. when the Repo was created.

source

pub fn git(&self, args: &[&str]) -> Result<String>

Run a git command in the repository git directory

source

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

source

pub fn checkout_last_commit_at_path(&self, path: &Path) -> Result<()>

Checkout to the latest commit.

source

pub fn checkout_previous_commit_at_path(&self, path: &Path) -> Result<()>

source

pub fn checkout(&self, object: &str) -> Result<()>

source

pub fn current_commit_message(&self) -> Result<String>

source

pub fn current_commit_hash(&self) -> Result<String>

source

pub fn tag(&self, name: &str) -> Result<String>

Create a git tag

source

pub fn get_tag_commit(&self, tag: &str) -> Option<String>

Get the commit hash of the given tag

source

pub fn is_ancestor( &self, maybe_ancestor_commit: &str, descendant_commit: &str ) -> bool

Check if a commit comes before another one.

Example

For this git log:

commit d6ec399b80d44bf9c4391e4a9ead8482faa9bffd
commit e880d8786cb16aa9a3f258e7503932445d708df7

git.is_ancestor("e880d8786cb16aa9a3f258e7503932445d708df7", "d6ec399b80d44bf9c4391e4a9ead8482faa9bffd") returns true.

source

pub fn original_remote_url(&self) -> Result<String>

Url of the remote when the Repo was created.

source

pub fn tag_exists(&self, tag: &str) -> Result<bool>

Trait Implementations§

source§

impl Debug for Repo

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Repo

§

impl Send for Repo

§

impl Sync for Repo

§

impl Unpin for Repo

§

impl UnwindSafe for Repo

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

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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

§

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

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more