Documentation
¶
Overview ¶
Package checkpoint snapshots working directories into shadow git repositories kept apart from the user's own repository, so file changes can be reviewed and undone. It never touches the user's index or history.
Index ¶
- Constants
- Variables
- type Change
- type Diff
- type Status
- type Store
- func (s *Store) Compare(ctx context.Context, dir string, trees []string) ([][]Change, error)
- func (s *Store) Diff(ctx context.Context, dir, from, to string, paths ...string) (Diff, error)
- func (s *Store) Prune(ctx context.Context, dir string, keep []string) error
- func (s *Store) Restore(ctx context.Context, dir, tree string) ([]Change, error)
- func (s *Store) Snapshot(ctx context.Context, dir string) (string, error)
Constants ¶
const MaxFiles = 50000
MaxFiles is the most files a directory may hold to be snapshotted.
Variables ¶
var ErrMissing = errors.New("the checkpoint is no longer available")
ErrMissing is returned for a snapshot the shadow repository no longer holds.
var ErrUnsupported = errors.New("checkpoints are not taken in this directory")
ErrUnsupported is returned for a directory that is not snapshotted: the home directory, a directory above it, the file system root, or one holding more than MaxFiles files.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
Path string `json:"path"`
Status Status `json:"status"`
Added int `json:"added"`
Deleted int `json:"deleted"`
Binary bool `json:"binary,omitempty"`
}
Change is one file a diff changes, by path relative to the working directory.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps one shadow repository per work tree under its root.
func (*Store) Diff ¶
Diff compares two snapshots of dir; an empty from or to is its current state. Paths, relative to dir, limit the diff.
func (*Store) Prune ¶
Prune drops the refs of the snapshots of dir that keep does not name, and repeated refs of one tree, and at most once per gcInterval collects the objects no ref reaches.