diff

package
v0.0.0-...-974e3f2 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package diff builds a deterministic unified diff from original writable file state to the current candidate. It does not overlay candidates or touch the repository.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicatePath means one input lists the same path more than once.
	ErrDuplicatePath = errors.New("duplicate path")
	// ErrInconsistent means the original and candidate path sets differ.
	ErrInconsistent = errors.New("inconsistent file universe")
)

Functions

func LineChanges

func LineChanges(before, after string) (added, removed int)

LineChanges counts approximate inserted and deleted lines from before to after. Lines keep their terminators. A missing final newline stays distinct. An empty string has no lines. Equal texts produce zero counts.

func Unified

func Unified(original, candidate []File) (string, error)

Unified returns the review diff from original writable state to the current candidate. An unchanged candidate returns an empty string. Context width is 3 lines.

Types

type File

type File struct {
	Path     string
	Absent   bool
	Contents string
}

File is one logical writable path. Absent is distinct from an existing file whose Contents are empty.

type PathError

type PathError struct {
	Path string
	Err  error
}

PathError attaches a repository-relative path to a sentinel error.

func (*PathError) Error

func (e *PathError) Error() string

func (*PathError) Unwrap

func (e *PathError) Unwrap() error

Jump to

Keyboard shortcuts

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