Help us shape the future of Go! Take the 2026 Go Developer Survey

snapshot

package
v1.133.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package snapshot records workspace states in a shadow git repository.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotGitRepository = errors.New("not a git repository")

ErrNotGitRepository means the requested directory is not inside a git worktree.

Functions

This section is empty.

Types

type FileDiff

type FileDiff struct {
	File      string `json:"file"`
	Patch     string `json:"patch"`
	Additions int    `json:"additions"`
	Deletions int    `json:"deletions"`
	Status    string `json:"status,omitempty"`
}

FileDiff describes one file in a diff between two snapshot tree hashes.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager opens per-worktree shadow repositories under a data directory.

func NewManager

func NewManager(dataDir string) *Manager

NewManager creates a snapshot manager rooted at dataDir.

func (*Manager) Cleanup

func (m *Manager) Cleanup(ctx context.Context, dir string) error

Cleanup runs garbage collection for the shadow repository containing dir.

func (*Manager) Open

func (m *Manager) Open(ctx context.Context, dir string) (*Repo, error)

Open returns the shadow repository for the git worktree containing dir.

type Patch

type Patch struct {
	Hash  string   `json:"hash"`
	Files []string `json:"files"`
}

Patch describes files changed since a snapshot tree hash.

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo is a shadow git repository paired with a source worktree.

func (*Repo) Cleanup

func (r *Repo) Cleanup(ctx context.Context) error

Cleanup runs git gc for this shadow repository.

func (*Repo) Diff

func (r *Repo) Diff(ctx context.Context, hash string) (string, error)

Diff returns a unified diff between hash and the current source state.

func (*Repo) DiffFull

func (r *Repo) DiffFull(ctx context.Context, from, to string) ([]FileDiff, error)

DiffFull returns file-level diff metadata between two snapshot tree hashes.

func (*Repo) Directory

func (r *Repo) Directory() string

Directory returns the directory used to scope pathspecs for this repo.

func (*Repo) GitDir

func (r *Repo) GitDir() string

GitDir returns the shadow git directory.

func (*Repo) Patch

func (r *Repo) Patch(ctx context.Context, hash string) (Patch, error)

Patch reports files that changed between hash and the current source state.

func (*Repo) Restore

func (r *Repo) Restore(ctx context.Context, hash string) error

Restore checks out all files from hash into the source worktree.

func (*Repo) Revert

func (r *Repo) Revert(ctx context.Context, patches []Patch) error

Revert restores or removes the files listed in patches.

func (*Repo) Track

func (r *Repo) Track(ctx context.Context) (string, error)

Track stages the current source worktree state and returns its tree hash.

func (*Repo) Worktree

func (r *Repo) Worktree() string

Worktree returns the source git worktree root.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL