diff

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package diff computes the resolved-context difference between two manifests. It is shared by the CLI's local (embedded) diff command and the HTTP API's /v1/diff handler, so the exact same algorithm backs both.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntryDiff

type EntryDiff struct {
	URI    string
	Status Status
	// SnapshotIDA/SnapshotIDB are "" when the URI is absent from that side;
	// every other *A/*B field is likewise only set for a side that's present.
	SnapshotIDA string
	SnapshotIDB string
	// SourceRevisionA/B and ObservedAtA/B are the snapshot's recorded
	// provenance — the source's own revision marker and when Readproof
	// observed it.
	SourceRevisionA string
	SourceRevisionB string
	ObservedAtA     time.Time
	ObservedAtB     time.Time
	// RefA/RefB are the "@<tag>" each side was mounted by, "" for a plain URI.
	RefA string
	RefB string
	// UnifiedDiff is set only when Status == StatusChanged.
	UnifiedDiff string
}

EntryDiff describes one URI's status between manifest A and manifest B. The per-side provenance fields answer "why did this change?" without a second round of lookups by the caller: they come from the snapshot each side's manifest entry names.

type Result

type Result struct {
	ManifestA manifest.Manifest
	ManifestB manifest.Manifest
	Entries   []EntryDiff
}

Result is the full comparison, entries sorted by URI.

func Compute

func Compute(ctx context.Context, manA, manB manifest.Manifest, blobs blob.Store, snapshots snapshot.Store) (Result, error)

Compute diffs manA against manB by URI and content hash, fetching blobs to render a unified diff for any changed entry and snapshots to attach each side's provenance. Taking the stores as arguments (rather than hydrating in the caller) keeps this the single place that knows how a diff is assembled, mirroring replay.Replayer.

func (Result) Counts

func (r Result) Counts() (changed, added, removed, unchanged int)

type Status

type Status string
const (
	StatusChanged   Status = "changed"
	StatusAdded     Status = "added"
	StatusRemoved   Status = "removed"
	StatusUnchanged Status = "unchanged"
)

Jump to

Keyboard shortcuts

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