diff

package
v0.10.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package diff provides semantic diff engines for pixi.toml and pixi.lock files.

The TOML diff engine parses pixi.toml files structurally and produces semantic diffs (e.g., "numpy upgraded from 2.0 to 2.4") rather than raw line-by-line text diffs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatLockDiffText

func FormatLockDiffText(summary *LockSummary) string

FormatLockDiffText formats a LockSummary as detailed text with package lists.

func FormatUnifiedDiff

func FormatUnifiedDiff(diff *TomlDiff, sourceLabel, targetLabel string) string

FormatUnifiedDiff formats a TomlDiff as a unified diff string.

Types

type Change

type Change struct {
	Section  string     `json:"section"`
	Key      string     `json:"key"`
	Type     ChangeType `json:"type"`
	OldValue string     `json:"old_value,omitempty"`
	NewValue string     `json:"new_value,omitempty"`
}

Change represents a single semantic change in a TOML file.

type ChangeType

type ChangeType string

ChangeType represents the type of change in a diff.

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

type LockSummary

type LockSummary struct {
	PackagesAdded   int             `json:"packages_added"`
	PackagesRemoved int             `json:"packages_removed"`
	PackagesUpdated int             `json:"packages_updated"`
	Added           []string        `json:"added,omitempty"`
	Removed         []string        `json:"removed,omitempty"`
	Updated         []PackageUpdate `json:"updated,omitempty"`
}

LockSummary represents a summary of lock file changes.

func CompareLock

func CompareLock(oldContent, newContent []byte) (*LockSummary, error)

CompareLock compares two pixi.lock file contents and produces a LockSummary. It parses the YAML structure and identifies added, removed, and updated packages.

type PackageUpdate

type PackageUpdate struct {
	Name       string `json:"name"`
	OldVersion string `json:"old"`
	NewVersion string `json:"new"`
}

PackageUpdate represents a package version change.

type TomlDiff

type TomlDiff struct {
	Changes []Change `json:"changes"`
}

TomlDiff represents the semantic difference between two TOML files.

func CompareToml

func CompareToml(oldContent, newContent []byte) (*TomlDiff, error)

CompareToml parses two TOML contents and produces a semantic diff.

func (*TomlDiff) Added

func (d *TomlDiff) Added() []Change

Added returns all added changes.

func (*TomlDiff) HasChanges

func (d *TomlDiff) HasChanges() bool

HasChanges returns true if there are any differences.

func (*TomlDiff) Modified

func (d *TomlDiff) Modified() []Change

Modified returns all modified changes.

func (*TomlDiff) Removed

func (d *TomlDiff) Removed() []Change

Removed returns all removed changes.

Jump to

Keyboard shortcuts

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