diff

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package diff implements snapshot differencing for JVS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Path      string      `json:"path"`
	Type      ChangeType  `json:"type"`
	Mode      os.FileMode `json:"mode,omitempty"`
	Size      int64       `json:"size,omitempty"`
	OldSize   int64       `json:"old_size,omitempty"`
	OldHash   string      `json:"old_hash,omitempty"`
	NewHash   string      `json:"new_hash,omitempty"`
	IsSymlink bool        `json:"is_symlink,omitempty"`
}

Change represents a single file/directory change between snapshots.

type ChangeType

type ChangeType string

ChangeType represents the type of filesystem change.

const (
	ChangeAdded    ChangeType = "added"
	ChangeRemoved  ChangeType = "removed"
	ChangeModified ChangeType = "modified"
)

type DiffResult

type DiffResult struct {
	FromSnapshotID model.SnapshotID `json:"from_snapshot_id"`
	ToSnapshotID   model.SnapshotID `json:"to_snapshot_id"`
	FromTime       time.Time        `json:"from_time"`
	ToTime         time.Time        `json:"to_time"`
	Added          []*Change        `json:"added"`
	Removed        []*Change        `json:"removed"`
	Modified       []*Change        `json:"modified"`
	TotalAdded     int              `json:"total_added"`
	TotalRemoved   int              `json:"total_removed"`
	TotalModified  int              `json:"total_modified"`
}

DiffResult represents the result of comparing two snapshots.

func (*DiffResult) FormatHuman

func (r *DiffResult) FormatHuman() string

FormatHuman returns a human-readable string representation of the diff.

func (*DiffResult) SetTimes

func (r *DiffResult) SetTimes(fromTime, toTime time.Time)

SetTimes sets the timestamp fields from descriptors.

type Differ

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

Differ computes differences between snapshots.

func NewDiffer

func NewDiffer(repoRoot string) *Differ

NewDiffer creates a new Differ.

func (*Differ) Diff

func (d *Differ) Diff(fromID, toID model.SnapshotID) (*DiffResult, error)

Diff compares two snapshots and returns the differences. If fromID is empty, compares against an empty snapshot (shows all as added).

Jump to

Keyboard shortcuts

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