Skip to main content

Repository

Struct Repository 

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

Implementations§

Source§

impl Repository

Source

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

Performs a soft reset to the parent of HEAD (HEAD~1).

This undoes the last commit while keeping changes staged.

§Errors

Returns an error if:

  • HEAD cannot be resolved
  • HEAD has no parent (initial commit)
  • The reset operation fails
Source

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

§Errors

Returns an error if the commit cannot be created.

Source§

impl Repository

Source

pub fn changed_files( &self, base: Option<&str>, head: &str, ) -> Result<Vec<FileChange>>

§Errors

Returns GitError::RefNotFound if either base or head cannot be resolved.

Source

pub fn changed_files_from_head(&self, base: &str) -> Result<Vec<FileChange>>

§Errors

Returns GitError::RefNotFound if the base reference cannot be resolved.

Source§

impl Repository

Source

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

§Errors

Returns GitError::FileDelete if the file cannot be deleted.

Source

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

§Errors

Returns GitError::FileDelete if any file cannot be deleted.

Source§

impl Repository

Source

pub fn remote_url(&self) -> Result<Option<String>>

§Errors

Returns an error if the remote lookup fails.

Source§

impl Repository

Source

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

§Errors

Returns an error if staging any of the files fails.

Source

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

§Errors

Returns an error if the staging operation fails.

Source§

impl Repository

Source

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

§Errors

Returns GitError::DetachedHead if HEAD is not on a branch.

Source

pub fn is_working_tree_clean(&self) -> Result<bool>

§Errors

Returns an error if the git status operation fails.

Source

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

§Errors

Returns GitError::DirtyWorkingTree if there are uncommitted changes.

Source§

impl Repository

Source

pub fn delete_tag(&self, name: &str) -> Result<bool>

Deletes a tag by name.

Returns Ok(true) if the tag was deleted, Ok(false) if the tag was not found.

§Errors

Returns an error if the delete operation fails for reasons other than “not found”.

Source

pub fn create_tag(&self, name: &str, message: &str) -> Result<TagInfo>

§Errors

Returns an error if the tag cannot be created or already exists.

Source§

impl Repository

Source

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

§Errors

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

Source

pub fn root(&self) -> &Path

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.