Skip to main content

Shadow

Struct Shadow 

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

Shadow git repository manager.

Implementations§

Source§

impl Shadow

Source

pub fn new(root: &Path) -> Self

Create a new Shadow instance for a project root.

Source

pub fn exists(&self) -> bool

Check if shadow git exists for this project.

Source

pub fn before_edit(&self, files: &[&Path]) -> Result<(), ShadowError>

Record file state before an edit. Call this before applying the edit to capture “before” state.

Source

pub fn after_edit(&self, info: &EditInfo) -> Result<(), ShadowError>

Record file state after an edit and commit. Call this after applying the edit to capture “after” state.

Source

pub fn history( &self, file_filter: Option<&str>, limit: usize, ) -> Vec<HistoryEntry>

Get history of shadow edits. Returns list of edits in reverse chronological order (newest first).

Source

pub fn diff(&self, commit_ref: &str) -> Option<String>

Get diff for a specific commit.

Source

pub fn tree(&self, limit: usize) -> Option<String>

Get tree view of shadow history (shows all branches with graph).

Source

pub fn checkpoint(&self) -> Option<String>

Get current checkpoint (last git commit in real repo when shadow was updated).

Source

pub fn validate( &self, cmd: &str, args: &[&str], ) -> Result<ValidationResult, ShadowError>

Run a validation command in the shadow worktree. Returns (success, stdout, stderr). Used by agents to test changes before applying to real files.

Source

pub fn apply_to_real(&self) -> Result<Vec<PathBuf>, ShadowError>

Apply pending shadow changes to the real worktree. Only call this after validation passes. Returns list of files that were updated.

Source

pub fn edit_count(&self) -> usize

Get the number of shadow commits (edits tracked).

Source

pub fn prune(&self, keep: usize) -> Result<usize, ShadowError>

Prune shadow history, keeping only the last N commits. Returns the number of commits pruned.

Source

pub fn undo( &self, count: usize, file_filter: Option<&str>, cross_checkpoint: bool, dry_run: bool, force: bool, ) -> Result<Vec<UndoResult>, ShadowError>

Undo the most recent edit (or specified number of edits). Returns information about what was undone.

If file_filter is Some, only undo changes to files matching that path. If force is false, checks for external modifications first and fails if any files have been modified outside of normalize.

If cross_checkpoint is false, refuses to undo past a git commit boundary.

Source

pub fn redo(&self) -> Result<UndoResult, ShadowError>

Redo the most recently undone edit. Only works if the last operation was an undo.

Source

pub fn goto( &self, ref_str: &str, dry_run: bool, force: bool, ) -> Result<UndoResult, ShadowError>

Jump to a specific commit in shadow history, restoring file state from that point. Can use full SHA, short SHA, or relative refs like HEAD~2.

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.