Struct rustgit::Repository

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

Local repository residing in memory

Implementations§

source§

impl Repository

source

pub fn new() -> Self

Creates an empty repository.

source

pub fn for_each_entry<F: FnMut(&str, Mode, Hash)>( &self, path: &str, entry_type: EntryType, callback: F ) -> Result<(), Error>

Returns an iterator on the contents of a directory that was staged or commited before.

Returns PathError if the path leads to nowhere.

This can write-lock an internal RwLock for cache.

source

pub fn read_file(&self, path: &str) -> Result<&[u8], Error>

Returns the content of a file that was staged or commited before.

Returns PathError if the path leads to nowhere.

This can write-lock an internal RwLock for cache.

source

pub fn file_exists(&self, path: &str) -> Result<bool, Error>

Returns the content of a file that was staged or commited before.

Returns PathError if the path leads to nowhere.

This can write-lock an internal RwLock for cache.

source

pub fn read_text(&self, path: &str) -> Result<&str, Error>

Returns the content of a textual file that was staged or commited before.

Returns PathError if the path leads to nowhere. Returns InvalidObject if the file contains non-utf-8 bytes.

This can write-lock an internal RwLock for cache.

source

pub fn stage( &mut self, path: &str, data: Option<(Vec<u8>, FileType)> ) -> Result<(), Error>

Place a new file in the workspace, which will be staged until the next call to Self::commit.

  • Missing directories are created as needed.
  • If data is None, any existing file at this path will be staged as deleted. If this leads to directories becoming empty, they will be deleted as well.

Should only fail if the repository was already corrupted.

source

pub fn commit( &mut self, message: &str, author: (&str, &str), committer: (&str, &str), timestamp: Option<u64> ) -> Result<Hash, Error>

Creates a new commit which saves staged files into the repository.

  • If timestamp is None, the current time will be used instead.
  • If one of the strings in author & committer contain invalid characters (<, > or \n), this returns InvalidObject immediately.
source

pub fn discard_commits(&mut self)

Resets the current commit to the branch head in upstream

Changes from the discarded commits are still present (staged).

source

pub fn discard_changes(&mut self)

Discard changes that weren’t commited

source

pub fn discard(&mut self)

Resets the clone to the upstream state

source§

impl Repository

source

pub fn clone( &mut self, remote: &Remote, reference: Reference<'_>, depth: Option<usize> ) -> Result<(), Error>

Imports objects from a remote repository based on a reference

Note: Can return Err(GitProtocolError) when an invalid Commit reference is specified (one which doesn’t exist on the remote end).

source

pub fn import_packfile( &mut self, packfile: Vec<u8>, head: Option<Hash> ) -> Result<(), Error>

source§

impl Repository

source

pub fn push( &mut self, remote: &Remote, updated_heads: &[(&str, Hash)], force_push: bool ) -> Result<(), Error>

Push committed changes upstream

source

pub fn pack<W: Write, F: Fn(&mut W, usize)>( &self, to_skip: HashSet<Hash>, heads_to_include: &[(&str, Hash)], dst: &mut W, size_hint: F ) -> Result<(), Error>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V