pub struct GitRepository { /* private fields */ }Expand description
A wrapper around gix::Repository providing a simplified interface
for Git repository operations.
Implementations§
Source§impl GitRepository
impl GitRepository
Sourcepub fn init(path: &Path) -> Result<Self>
pub fn init(path: &Path) -> Result<Self>
Initialize a new Git repository at the given path.
Creates the directory (and parents) if it does not exist, then
initializes a standard (non-bare) Git repository with a .git directory.
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Get the working directory path of the repository.
Returns the working tree directory if available, otherwise falls back
to the .git directory itself.
Sourcepub fn inner(&self) -> &Repository
pub fn inner(&self) -> &Repository
Get a reference to the inner gix::Repository.
Sourcepub fn commit(
&self,
message: &str,
author_name: &str,
author_email: &str,
) -> Result<String>
pub fn commit( &self, message: &str, author_name: &str, author_email: &str, ) -> Result<String>
Create a Git commit with the current working directory state. Uses command-line git for simplicity (gix’s commit API is complex).
Sourcepub fn read_tree_entry(&self, commit_hex: &str, path: &str) -> Result<Vec<u8>>
pub fn read_tree_entry(&self, commit_hex: &str, path: &str) -> Result<Vec<u8>>
Read a file’s content from a specific commit’s tree (NOT the working directory). This is the core isolation primitive for Native Session Isolation.
commit_hex — hex SHA of the commit whose tree to read from.
path — relative file path within the tree (e.g. “src/main.rs”).
Returns the raw bytes of the blob, or an error if the commit / path does not exist or the entry is not a blob.
Sourcepub fn list_tree_files(&self, commit_hex: &str) -> Result<Vec<String>>
pub fn list_tree_files(&self, commit_hex: &str) -> Result<Vec<String>>
List all files (recursive) in a commit’s tree. Returns relative paths using forward-slash separators.
Only non-tree entries (blobs, symlinks, submodules) are included.
Sourcepub fn commit_tree_overlay(
&self,
base_commit_hex: &str,
overlay: &[(String, Option<Vec<u8>>)],
parent_commit_hex: &str,
message: &str,
author_name: &str,
author_email: &str,
) -> Result<String>
pub fn commit_tree_overlay( &self, base_commit_hex: &str, overlay: &[(String, Option<Vec<u8>>)], parent_commit_hex: &str, message: &str, author_name: &str, author_email: &str, ) -> Result<String>
Build a new git tree by applying overlay changes on a base tree, create a commit, and update the working directory.
For each overlay entry:
Some(content)→ upsert a blob at that pathNone→ delete the entry at that path
After committing, the working directory is updated via git checkout HEAD -- ..
Returns the hex SHA of the new commit.
Sourcepub fn commit_initial_overlay(
&self,
overlay: &[(String, Option<Vec<u8>>)],
message: &str,
author_name: &str,
author_email: &str,
) -> Result<String>
pub fn commit_initial_overlay( &self, overlay: &[(String, Option<Vec<u8>>)], message: &str, author_name: &str, author_email: &str, ) -> Result<String>
Create an orphan commit from overlay entries on an empty repository (no existing commits). This is used for the very first commit.
Builds a tree from scratch using only the overlay entries (ignoring
None/deletion entries since there’s nothing to delete), creates a
root commit with no parents, and updates HEAD.
Returns the hex SHA of the new commit.
Auto Trait Implementations§
impl !Freeze for GitRepository
impl !RefUnwindSafe for GitRepository
impl Send for GitRepository
impl !Sync for GitRepository
impl Unpin for GitRepository
impl UnsafeUnpin for GitRepository
impl !UnwindSafe for GitRepository
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more