GitRepo

Struct GitRepo 

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

A git repository wrapper for parsing commits

Implementations§

Source§

impl GitRepo

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, GitError>

Open a git repository at the given path

§Errors

Returns GitError::RepositoryNotFound if the path is not a git repository.

Source

pub fn discover(path: impl AsRef<Path>) -> Result<Self, GitError>

Discover and open a git repository containing the given path

This walks up the directory tree to find a .git directory.

§Errors

Returns GitError::RepositoryNotFound if no repository is found.

Source

pub fn is_bare(&self) -> bool

Check if the repository is bare

Source

pub fn path(&self) -> &Path

Get the repository path

Source

pub fn workdir(&self) -> Option<&Path>

Get the working directory path (None for bare repos)

Source

pub fn walk_commits( &self, options: &WalkOptions, ) -> Result<Vec<CommitWithDiff>, GitError>

Walk commits according to the given options

§Errors

Returns GitError if the repository cannot be walked.

Source

pub fn get_commit(&self, reference: &str) -> Result<CommitWithDiff, GitError>

Get a single commit by SHA or reference

§Errors

Returns GitError::InvalidReference if the reference cannot be resolved.

Source

pub fn head_sha(&self) -> Result<String, GitError>

Get the HEAD commit SHA

§Errors

Returns GitError if HEAD cannot be resolved.

Source

pub fn commit_count(&self) -> Result<usize, GitError>

Count commits in the repository

§Errors

Returns GitError if the repository cannot be walked.

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.