store

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OopsDir       = ".oops"
	GlobalOopsDir = ".oops" // stored in user home directory
)

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

func CheckDuplicateTracking added in v0.3.0

func CheckDuplicateTracking(filePath string) (bool, bool)

CheckDuplicateTracking checks if file is tracked in both local and global Returns (hasLocal, hasGlobal)

func GetGlobalOopsDir added in v0.3.0

func GetGlobalOopsDir() (string, error)

GetGlobalOopsDir returns the global .oops directory path

Types

type GlobalStoreInfo added in v0.3.0

type GlobalStoreInfo struct {
	FilePath string
	FileName string
	HashDir  string
}

GlobalStoreInfo represents info about a globally tracked file

func ListGlobalStores added in v0.3.0

func ListGlobalStores() ([]GlobalStoreInfo, error)

ListGlobalStores returns all globally tracked files

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
	Global   bool // true if using global storage
}

Store manages versioning for a single file using Git backend

func FindGlobalStore added in v0.3.0

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

FindGlobalStore finds an existing global store for a file path

func NewGlobalStore added in v0.3.0

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

NewGlobalStore creates a store instance for a file (global mode)

func NewStore

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

NewStore creates a store instance for a file (local mode)

func NewStoreWithOptions added in v0.3.0

func NewStoreWithOptions(filePath string, opts StoreOptions) (*Store, error)

NewStoreWithOptions creates a store instance with specified options

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)

type StoreOptions added in v0.3.0

type StoreOptions struct {
	Global bool // Use global storage in user home directory
}

StoreOptions configures Store behavior

Jump to

Keyboard shortcuts

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