diff

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package diff parses unified diffs into structured representations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineFileChanges

func CombineFileChanges(changes []FileChangeInput) string

CombineFileChanges builds a unified diff string from file change inputs.

func Summary

func Summary(files []File) string

Summary returns a human-readable summary of the diff.

Types

type File

type File struct {
	Path    string
	OldPath string
	Hunks   []Hunk
	Added   bool
	Deleted bool
	Renamed bool
}

File represents a single file's changes in a diff.

func Parse

func Parse(raw string) []File

Parse converts a unified diff string into structured File objects.

type FileChangeInput

type FileChangeInput struct {
	Path    string
	OldPath string
	Diff    string
	Content string
}

FileChangeInput is the input type for CombineFileChanges.

type Hunk

type Hunk struct {
	OldStart int
	OldCount int
	NewStart int
	NewCount int
	Header   string
	Lines    []Line
}

Hunk represents a contiguous set of changes within a file.

type Line

type Line struct {
	Type    LineType
	Content string
	OldNum  int
	NewNum  int
}

Line represents a single line in a hunk.

type LineType

type LineType int

LineType indicates whether a line was added, removed, or is context.

const (
	LineContext LineType = iota
	LineAdded
	LineRemoved
)

Jump to

Keyboard shortcuts

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