pub struct Shadow { /* private fields */ }Expand description
Shadow git repository manager.
Implementations§
Source§impl Shadow
impl Shadow
Sourcepub fn before_edit(&self, files: &[&Path]) -> Result<(), ShadowError>
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.
Sourcepub fn after_edit(&self, info: &EditInfo) -> Result<(), ShadowError>
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.
Sourcepub fn history(
&self,
file_filter: Option<&str>,
limit: usize,
) -> Vec<HistoryEntry>
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).
Sourcepub fn tree(&self, limit: usize) -> Option<String>
pub fn tree(&self, limit: usize) -> Option<String>
Get tree view of shadow history (shows all branches with graph).
Sourcepub fn checkpoint(&self) -> Option<String>
pub fn checkpoint(&self) -> Option<String>
Get current checkpoint (last git commit in real repo when shadow was updated).
Sourcepub fn validate(
&self,
cmd: &str,
args: &[&str],
) -> Result<ValidationResult, ShadowError>
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.
Sourcepub fn apply_to_real(&self) -> Result<Vec<PathBuf>, ShadowError>
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.
Sourcepub fn edit_count(&self) -> usize
pub fn edit_count(&self) -> usize
Get the number of shadow commits (edits tracked).
Sourcepub fn prune(&self, keep: usize) -> Result<usize, ShadowError>
pub fn prune(&self, keep: usize) -> Result<usize, ShadowError>
Prune shadow history, keeping only the last N commits. Returns the number of commits pruned.
Sourcepub fn undo(
&self,
count: usize,
file_filter: Option<&str>,
cross_checkpoint: bool,
dry_run: bool,
force: bool,
) -> Result<Vec<UndoResult>, ShadowError>
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.
Sourcepub fn redo(&self) -> Result<UndoResult, ShadowError>
pub fn redo(&self) -> Result<UndoResult, ShadowError>
Redo the most recently undone edit. Only works if the last operation was an undo.
Sourcepub fn goto(
&self,
ref_str: &str,
dry_run: bool,
force: bool,
) -> Result<UndoResult, ShadowError>
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.