Documentation
¶
Index ¶
- Constants
- func LatestStashRef(ctx context.Context) string
- type FileBackup
- type Op
- type Recorder
- func (r *Recorder) BackupFile(op *Op, path string) error
- func (r *Recorder) Begin(ctx context.Context, command, opType string) *Op
- func (r *Recorder) CaptureRemoteSha(ctx context.Context, op *Op, remote, branch string)
- func (r *Recorder) Commit(ctx context.Context, op *Op) error
- func (r *Recorder) CreateBackupRef(ctx context.Context, op *Op)
- func (r *Recorder) Fail(ctx context.Context, op *Op, errMsg string)
- func (r *Recorder) MarkIrreversible(op *Op, reason string)
- type Store
Constants ¶
const Cap = 50
Cap on stored checkpoints per repo. Older entries pruned.
Variables ¶
This section is empty.
Functions ¶
func LatestStashRef ¶
LatestStashRef returns sha of stash@{0} (the just-pushed stash).
Types ¶
type FileBackup ¶
FileBackup records a single file backed up before overwrite.
type Op ¶
type Op struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Command string `json:"command"`
OpType string `json:"op_type"`
Branch string `json:"branch,omitempty"`
HeadBefore string `json:"head_before,omitempty"`
HeadAfter string `json:"head_after,omitempty"`
BackupRef string `json:"backup_ref,omitempty"`
StashRef string `json:"stash_ref,omitempty"`
Remote string `json:"remote,omitempty"`
RemoteBranch string `json:"remote_branch,omitempty"`
RemoteSHABefore string `json:"remote_sha_before,omitempty"`
RemoteSHAAfter string `json:"remote_sha_after,omitempty"`
PRNumber string `json:"pr_number,omitempty"`
PRURL string `json:"pr_url,omitempty"`
FilesWritten []FileBackup `json:"files_written,omitempty"`
Args map[string]string `json:"args,omitempty"`
Reversible bool `json:"reversible"`
ReasonIfNot string `json:"reason_if_not,omitempty"`
Status string `json:"status"`
Note string `json:"note,omitempty"`
}
Op is a single recorded mutation. Status: pending|done|failed|undone. OpType: commit|rebase|merge|stash|push|pr_create|file_write.
type Recorder ¶
Recorder wraps Store with helpers to capture git state and create backups.
func NewRecorder ¶
func (*Recorder) BackupFile ¶
BackupFile copies file to .gitmate/backups/<id>/<flat-path> and records it. Used before overwriting a file (e.g., conflict resolution write).
func (*Recorder) Begin ¶
Begin creates an Op with a fresh ID, captures HEAD + branch, and returns it. Caller fills extra fields then calls Commit/Fail.
func (*Recorder) CaptureRemoteSha ¶
CaptureRemoteSha records the remote tip so an undo can force-with-lease back.
func (*Recorder) CreateBackupRef ¶
CreateBackupRef sets refs/gitmate/backup/<id> to current HEAD so destructive rebase/merge can be reset later. Best-effort; failure does not block op.
func (*Recorder) Fail ¶
Fail marks Op failed and persists. Cleans up backup ref since op did not land.
func (*Recorder) MarkIrreversible ¶
MarkIrreversible sets reversible=false with reason.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists Ops as JSON in <repo>/.gitmate/checkpoints.json.
func (*Store) LastUndoable ¶
LastUndoable returns most recent op that can still be undone.