delta

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package delta implements file version tracking and diff-based compression.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitDelta

type CommitDelta struct {
	CommitHash string
	ParentHash string
	Files      []FileDelta
}

CommitDelta represents changes in a commit.

type CompressionDecision

type CompressionDecision struct {
	UseDelta         bool
	BaseHash         string
	FullContent      bool
	EstimatedSavings int
}

CompressionDecision determines how to compress content.

type FileDelta

type FileDelta struct {
	Path       string
	OldHash    string
	NewHash    string
	ChangeType string // added, modified, deleted
}

FileDelta represents a file change.

type GitIntegration

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

GitIntegration provides git-aware delta tracking.

func NewGitIntegration

func NewGitIntegration(manager *Manager) *GitIntegration

NewGitIntegration creates git integration.

func (*GitIntegration) GetCommitDelta

func (g *GitIntegration) GetCommitDelta(repoPath, commitHash string) (*CommitDelta, error)

GetCommitDelta returns delta for a commit.

func (*GitIntegration) TrackChangedFiles

func (g *GitIntegration) TrackChangedFiles(repoPath string, sinceRef string) ([]string, error)

TrackChangedFiles tracks files changed since a ref.

type Manager

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

Manager tracks file versions and computes deltas.

func NewManager

func NewManager(baseDir string) *Manager

NewManager creates a new delta manager.

func (*Manager) Cleanup

func (m *Manager) Cleanup(path string, keep int) error

Cleanup removes old versions.

func (*Manager) ComputeDiff

func (m *Manager) ComputeDiff(path string, fromHash, toHash string) (filter.IncrementalDelta, error)

ComputeDiff returns the diff between two versions.

func (*Manager) DecideCompression

func (m *Manager) DecideCompression(path string, content string) CompressionDecision

DecideCompression determines the best compression strategy.

func (*Manager) Get

func (m *Manager) Get(path string, hash string) (*Version, error)

Get retrieves a specific version by hash.

func (*Manager) GetLatest

func (m *Manager) GetLatest(path string) (*Version, error)

GetLatest retrieves the latest version.

func (*Manager) GetVersions

func (m *Manager) GetVersions(path string) []*Version

GetVersions returns all versions for a path.

func (*Manager) Load

func (m *Manager) Load() error

Load loads versions from disk.

func (*Manager) Save

func (m *Manager) Save() error

Save persists versions to disk.

func (*Manager) ShouldCompress

func (m *Manager) ShouldCompress(path string, content string) (bool, string)

ShouldCompress determines if delta compression should be used.

func (*Manager) Stats

func (m *Manager) Stats() Stats

Stats returns manager statistics.

func (*Manager) Track

func (m *Manager) Track(path string, content string) (*Version, error)

Track adds a new version of a file.

type Stats

type Stats struct {
	FilesTracked  int
	TotalVersions int
	TotalSize     int64
}

Stats provides statistics about the manager.

type Version

type Version struct {
	Hash      string    `json:"hash"`
	Content   string    `json:"content"`
	Timestamp time.Time `json:"timestamp"`
	Size      int64     `json:"size"`
	DiffFrom  string    `json:"diff_from,omitempty"` // Hash of parent version
}

Version represents a stored file version.

Jump to

Keyboard shortcuts

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