Skip to main content

GitVfs

Struct GitVfs 

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

Git-aware filesystem backend.

Wraps LocalFs for file operations while tracking git repository state. All file operations go through the local filesystem, with git operations available through dedicated methods.

Implementations§

Source§

impl GitVfs

Source

pub fn open(path: impl Into<PathBuf>) -> Result<Self, GitError>

Open an existing git repository.

The path should point to a directory containing a .git folder (or the .git folder itself for bare repos).

Source

pub fn clone(url: &str, path: impl Into<PathBuf>) -> Result<Self, GitError>

Clone a repository from a URL.

Source

pub fn init(path: impl Into<PathBuf>) -> Result<Self, GitError>

Initialize a new git repository.

Source

pub fn root(&self) -> &Path

Get the root path of the repository.

Source

pub fn status(&self) -> Result<Vec<FileStatus>, GitError>

Get the current status of the working tree.

Source

pub fn status_summary(&self) -> Result<StatusSummary, GitError>

Get a simplified status summary.

Source

pub fn add(&self, pathspec: &[&str]) -> Result<(), GitError>

Add files to the git index (staging area).

Supports glob patterns (e.g., “.rs”, “src/**/.rs”).

Source

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

Add a specific file to the index.

Source

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

Remove a file from the index (unstage).

Source

pub fn commit( &self, message: &str, author: Option<&str>, ) -> Result<Oid, GitError>

Create a commit with the staged changes.

Source

pub fn log(&self, count: usize) -> Result<Vec<LogEntry>, GitError>

Get recent commit log entries.

Source

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

Get diff between working tree and HEAD.

Source

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

Get the current branch name.

Source

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

List all local branches.

Source

pub fn create_branch(&self, name: &str) -> Result<(), GitError>

Create a new branch.

Source

pub fn checkout(&self, target: &str) -> Result<(), GitError>

Checkout a branch or commit.

If force is true, overwrites local changes. If false, fails if there are uncommitted changes that would be overwritten.

Source

pub fn checkout_with_options( &self, target: &str, force: bool, ) -> Result<(), GitError>

Checkout with explicit force option.

If force is false, checkout will fail if there are uncommitted changes that would be overwritten by the checkout.

Source

pub fn worktrees(&self) -> Result<Vec<WorktreeInfo>, GitError>

List all worktrees attached to this repository.

Returns the main worktree plus any linked worktrees.

Source

pub fn worktree_add( &self, name: &str, path: &Path, committish: Option<&str>, ) -> Result<WorktreeInfo, GitError>

Add a new worktree.

Creates a new worktree at path with the given name.

The committish parameter accepts:

  • Local branch names (feature, main)
  • Remote tracking branches (origin/main)
  • Commit SHAs (abc1234)
  • Tags (v1.0.0)
  • Any git revision (HEAD~3)

If committish is None, creates a new branch with the worktree name.

Source

pub fn worktree_remove(&self, name: &str, force: bool) -> Result<(), GitError>

Remove a worktree.

The worktree must not be locked and must be prunable (no uncommitted changes). Use force to remove even if it has changes.

Source

pub fn worktree_lock( &self, name: &str, reason: Option<&str>, ) -> Result<(), GitError>

Lock a worktree to prevent it from being pruned.

Source

pub fn worktree_unlock(&self, name: &str) -> Result<(), GitError>

Unlock a worktree.

Source

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

Prune stale worktree information.

Removes worktree entries that no longer exist on disk.

Trait Implementations§

Source§

impl Debug for GitVfs

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Filesystem for GitVfs

Source§

fn read<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read the entire contents of a file.
Source§

fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, path: &'life1 Path, data: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Write data to a file, creating it if it doesn’t exist. Read more
Source§

fn list<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<DirEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List entries in a directory.
Source§

fn stat<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get metadata for a file or directory.
Source§

fn mkdir<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a directory (and parent directories if needed). Read more
Source§

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a file or empty directory. Read more
Source§

fn rename<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, from: &'life1 Path, to: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Rename (move) a file or directory. Read more
Source§

fn read_only(&self) -> bool

Returns true if this filesystem is read-only.
Source§

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a path exists.
Source§

fn real_path(&self, path: &Path) -> Option<PathBuf>

Get the real filesystem path for a VFS path. Read more
Read the target of a symbolic link without following it. Read more
Create a symbolic link. Read more
Source§

fn lstat<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get metadata for a path without following symlinks. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more