Documentation
¶
Overview ¶
Package rollback provides a commit chain browser for M31A sessions. It lists session commits, supports soft and hard resets to any point in the chain, and creates backup branches before destructive operations.
Index ¶
- Variables
- type Rollback
- func (r *Rollback) Chain(limit int) ([]RollbackEntry, error)
- func (r *Rollback) CurrentHead() (string, error)
- func (r *Rollback) HardReset(hash string) (*RollbackResult, error)
- func (r *Rollback) HasUncommittedChanges() (bool, error)
- func (r *Rollback) Preview(hash string) (string, error)
- func (r *Rollback) SafeReset(hash string) (*RollbackResult, error)
- func (r *Rollback) SoftReset(hash string, onReset func(newHead string) error) (*RollbackResult, error)
- type RollbackEntry
- type RollbackResult
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidHash = errors.New("invalid commit hash")
ErrInvalidHash is returned when a commit hash is not found in the repository.
Functions ¶
This section is empty.
Types ¶
type Rollback ¶
type Rollback struct {
// contains filtered or unexported fields
}
Rollback provides safe commit rollback operations.
func (*Rollback) Chain ¶
func (r *Rollback) Chain(limit int) ([]RollbackEntry, error)
Chain returns up to `limit` commits newest-first with their diffs to HEAD. If limit <= 0, defaults to 20. The current HEAD is at index 0. Returns an empty slice for empty repos without error.
func (*Rollback) CurrentHead ¶
CurrentHead returns the full SHA of the current HEAD commit.
func (*Rollback) HardReset ¶
func (r *Rollback) HardReset(hash string) (*RollbackResult, error)
HardReset performs a git reset --hard to the given commit. If uncommitted changes exist, they are stashed first. C-11: Creates a timestamped backup branch before the destructive reset.
func (*Rollback) HasUncommittedChanges ¶
HasUncommittedChanges returns true if the working tree has uncommitted changes (modified, staged, untracked, or deleted files). Uses porcelain format for reliable, locale-independent parsing.
func (*Rollback) Preview ¶
Preview returns the diff between the given commit hash and HEAD. Output is capped at types.BashOutputLimit (50,000 characters).
func (*Rollback) SafeReset ¶
func (r *Rollback) SafeReset(hash string) (*RollbackResult, error)
SafeReset performs a git reset --hard to the given commit and then pops the stash to preserve any uncommitted changes.
func (*Rollback) SoftReset ¶
func (r *Rollback) SoftReset(hash string, onReset func(newHead string) error) (*RollbackResult, error)
SoftReset performs a git reset --soft to the given commit. If uncommitted changes exist, they are stashed first. The onReset callback, if non-nil, is called after the reset succeeds with the new HEAD hash. Use this to sync TASKS.md status updates (M-28).
type RollbackEntry ¶
type RollbackEntry struct {
CommitInfo git.CommitInfo `json:"commit_info"`
Diff string `json:"diff"`
IsCurrent bool `json:"is_current"`
HasCheckpoint bool `json:"has_checkpoint"`
}
RollbackEntry represents a single commit in the rollback chain.