Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("rewind manager closed")
ErrClosed is returned after Cleanup; callers should treat it as a transient no-op (RestartRewind installs a fresh Manager).
Functions ¶
func CleanupOrphans ¶ added in v0.6.2
func CleanupOrphans()
CleanupOrphans removes leftover shadow repos from prior crashed sessions. Only deletes dirs older than the cutoff so concurrent sessions are safe.
Types ¶
type FileDiff ¶
type FileDiff struct {
Path string
Status FileStatus
Patch string
Original string
Modified string
}
type FileStatus ¶
type FileStatus int
const ( StatusAdded FileStatus = iota StatusModified StatusDeleted )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager runs a shadow git repo in /tmp that snapshots the working dir on each user turn. Init is async; methods block on initDone until ready.
func (*Manager) Cleanup ¶
func (m *Manager) Cleanup()
Cleanup wipes the shadow repo. It waits for init and any in-flight DiffFromBaseline / Commit / List / Restore (wiping gitDir mid-snapshot surfaces "entry not found" from go-git), but only up to a bound — a minutes-long snapshot on a big repo must not hang app shutdown. On timeout the wipe completes in the background once the op finishes, or CleanupOrphans removes the dir on a later start.
func (*Manager) DiffFromBaseline ¶
DiffFromBaseline diffs the baseline against the live working tree (not HEAD), so changes from any source — agent tools, terminal, external editor — are reflected. Returns (nil, nil) when there's no diff; errors are reserved for actual git failures.
func (*Manager) Fingerprint ¶ added in v0.6.2
Fingerprint returns a 64-bit digest of the worktree's visible state (relative path, mtime, size for every non-ignored file). Doesn't hash content, so a `touch` will fire a refetch even when no diff changed. Per-file digests combine via XOR, so the scan parallelizes across subdirectories without ordering concerns.
func (*Manager) List ¶
func (m *Manager) List() ([]Checkpoint, error)