store

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OopsDir = ".oops"
)

Variables

View Source
var (
	ErrNotTracked         = errors.New("file is not tracked")
	ErrAlreadyTracked     = errors.New("file is already tracked")
	ErrNoChanges          = errors.New("no changes to save")
	ErrVersionNotFound    = errors.New("version not found")
	ErrUncommittedChanges = errors.New("uncommitted changes exist")
)

Functions

This section is empty.

Types

type Snapshot

type Snapshot = git.Snapshot

Snapshot represents a version snapshot (re-exported from git package)

type Store

type Store struct {
	FilePath string
	FileName string
	BaseDir  string
	GitDir   string
	Repo     *git.Repo
}

Store manages versioning for a single file using Git backend

func NewStore

func NewStore(filePath string) (*Store, error)

NewStore creates a store instance for a file

func (*Store) Back

func (s *Store) Back(num int, force bool) error

Back restores a specific version (back/checkout)

func (*Store) Changes

func (s *Store) Changes(versions ...int) (string, error)

Changes returns diff output (changes/diff)

func (*Store) Delete

func (s *Store) Delete() error

Delete removes the store (done/untrack)

func (*Store) Exists

func (s *Store) Exists() bool

Exists checks if the store exists (file is tracked)

func (*Store) GetLatestVersion

func (s *Store) GetLatestVersion() (int, error)

GetLatestVersion returns the latest version number

func (*Store) History

func (s *Store) History() ([]Snapshot, error)

History returns all snapshots (history/log)

func (*Store) Initialize

func (s *Store) Initialize() error

Initialize creates a new store for tracking (start/track)

func (*Store) Now

func (s *Store) Now() (current int, latest int, hasChanges bool, err error)

Now returns current status (now/status)

func (*Store) OopsDirPath

func (s *Store) OopsDirPath() string

OopsDirPath returns the path to .oops directory

func (*Store) Save

func (s *Store) Save(message string) (*Snapshot, error)

Save creates a new snapshot (save/commit)

func (*Store) ShouldCompress

func (s *Store) ShouldCompress() bool

ShouldCompress checks if the tracked file should be compressed

func (*Store) Undo

func (s *Store) Undo() error

Undo restores to HEAD (undo unsaved changes)

Jump to

Keyboard shortcuts

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