diff

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package diff implements helpers for comparing two filesystems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrecedingSnapshot added in v0.20.0

func GetPrecedingSnapshot(ctx context.Context, rep repo.Repository, snapshotID string) (*snapshot.Manifest, error)

GetPrecedingSnapshot fetches the snapshot manifest for the snapshot immediately preceding the given snapshotID if it exists.

func GetTwoLatestSnapshotsForASource added in v0.20.0

func GetTwoLatestSnapshotsForASource(ctx context.Context, rep repo.Repository, source snapshot.SourceInfo) (secondLast, last *snapshot.Manifest, err error)

GetTwoLatestSnapshotsForASource fetches two latest snapshot manifests for a given source if they exist.

Types

type Comparer

type Comparer struct {
	DiffCommand   string
	DiffArguments []string
	// contains filtered or unexported fields
}

Comparer outputs diff information between two filesystems.

func NewComparer

func NewComparer(out io.Writer, statsOnly bool) (*Comparer, error)

NewComparer creates a comparer for a given repository that will output the results to a given writer.

func (*Comparer) Close

func (c *Comparer) Close() error

Close removes all temporary files used by the comparer.

func (*Comparer) Compare

func (c *Comparer) Compare(ctx context.Context, e1, e2 fs.Entry) (Stats, error)

Compare compares two filesystem entries and emits their diff information.

func (*Comparer) Stats added in v0.20.0

func (c *Comparer) Stats() Stats

Stats returns aggregated statistics computed during snapshot comparison must be invoked after a call to Compare which populates ComparerStats struct.

type EntryTypeStats added in v0.20.0

type EntryTypeStats struct {
	Added    uint32 `json:"added"`
	Removed  uint32 `json:"removed"`
	Modified uint32 `json:"modified"`

	// aggregate stats
	SameContentButDifferentMetadata uint32 `json:"sameContentButDifferentMetadata"`

	// stats categorized based on metadata
	SameContentButDifferentMode             uint32 `json:"sameContentButDifferentMode"`
	SameContentButDifferentModificationTime uint32 `json:"sameContentButDifferentModificationTime"`
	SameContentButDifferentUserOwner        uint32 `json:"sameContentButDifferentUserOwner"`
	SameContentButDifferentGroupOwner       uint32 `json:"sameContentButDifferentGroupOwner"`
}

EntryTypeStats accumulates stats for an FS entry type.

type Stats added in v0.20.0

type Stats struct {
	FileEntries      EntryTypeStats `json:"fileEntries"`
	DirectoryEntries EntryTypeStats `json:"directoryEntries"`
}

Stats accumulates stats between snapshots being compared.

Jump to

Keyboard shortcuts

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