Repository

Struct Repository 

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

Implementations§

Source§

impl Repository

Source

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

Add specific files or paths to the staging area.

§Arguments
  • paths - The file paths to add to the staging area
§Returns

A Result indicating success or a GitError if the operation fails.

Source

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

Add all changes to the staging area (equivalent to git add .).

§Returns

A Result indicating success or a GitError if the operation fails.

Source

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

Add all tracked files that have been modified (equivalent to git add -u).

§Returns

A Result indicating success or a GitError if the operation fails.

Source§

impl Repository

Source

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

Create a commit with the given message.

§Arguments
  • message - The commit message
§Returns

A Result containing the Hash of the new commit or a GitError.

Source

pub fn commit_with_author(&self, message: &str, author: &str) -> Result<Hash>

Create a commit with the given message and author.

§Arguments
  • message - The commit message
  • author - The author in format “Name email@example.com
§Returns

A Result containing the Hash of the new commit or a GitError.

Source§

impl Repository

Source

pub fn status(&self) -> Result<GitStatus>

Get the status of the repository.

§Returns

A Result containing the GitStatus or a GitError.

Source§

impl Repository

Source

pub fn ensure_git() -> Result<()>

Ensure that Git is available in the system PATH.

This function checks if the git command is available in the system PATH. The result is cached, so subsequent calls are very fast. If Git is not found, it returns a GitError::CommandFailed with an appropriate error message.

§Returns

A Result containing either Ok(()) if Git is available or a GitError.

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open an existing Git repository at the specified path.

§Arguments
  • path - The path to an existing Git repository.
§Returns

A Result containing either the opened Repository instance or a GitError.

Source

pub fn init<P: AsRef<Path>>(path: P, bare: bool) -> Result<Self>

Initialize a new Git repository at the specified path.

§Arguments
  • path - The path where the repository should be initialized.
  • bare - Whether the repository should be bare or not.
§Returns

A Result containing either the initialized Repository instance or a GitError.

Source

pub fn repo_path(&self) -> &Path

Trait Implementations§

Source§

impl Debug for Repository

Source§

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

Formats the value using the given formatter. Read more

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.