diff

package
v0.13.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildHunkPatch

func BuildHunkPatch(parsed ParsedDiff, hunkIndex int) (string, error)

func BuildLineRangePatch

func BuildLineRangePatch(parsed ParsedDiff, startChanged, endChanged int) (string, error)

func BuildRawToDisplayMap

func BuildRawToDisplayMap(parsed ParsedDiff, displayToRaw []int) []int

func BuildSingleLinePatch

func BuildSingleLinePatch(parsed ParsedDiff, changedIndex int) (string, error)

func CleanHunkHeader

func CleanHunkHeader(line string) string

func DiffBodyPadding

func DiffBodyPadding(kind RowKind, width int) string

func HasBinaryDiff

func HasBinaryDiff(parsed ParsedDiff) bool

func SanitizeANSIInline

func SanitizeANSIInline(s string) string

func SectionHasBinaryDiff

func SectionHasBinaryDiff(parsed ParsedDiff) bool

func StripUnifiedVisibleMarker

func StripUnifiedVisibleMarker(line string, marker byte) string

func WrapANSI

func WrapANSI(s string, width int) []string

Types

type ChangedLine

type ChangedLine struct {
	LineIndex int
	HunkIndex int
	Prefix    byte
	Text      string
	OldLine   int
	NewLine   int
}

type ParsedDiff

type ParsedDiff struct {
	FileHeader []string
	Lines      []string
	Hunks      []ParsedHunk
	Changed    []ChangedLine
}

func ParseUnifiedDiff

func ParseUnifiedDiff(raw string) ParsedDiff

type ParsedHunk

type ParsedHunk struct {
	Header            string
	StartLine         int
	EndLine           int
	OldStart          int
	OldCount          int
	NewStart          int
	NewCount          int
	ChangedLineOffset []int
}

type RowKind

type RowKind int
const (
	RowPlain RowKind = iota
	RowAdded
	RowRemoved
	RowHunkHeader
)

func BuildDisplayBaseLines

func BuildDisplayBaseLines(parsed ParsedDiff, colorLines []string) (lines []string, kinds []RowKind, displayToRaw []int)

type SymlinkDiffInfo

type SymlinkDiffInfo struct {
	IsSymlink    bool
	WasSymlink   bool
	IsNowSymlink bool
	TypeChange   bool
	OldTarget    string
	NewTarget    string
}

func ParseSymlinkDiffInfo

func ParseSymlinkDiffInfo(parsed ParsedDiff) SymlinkDiffInfo

func (SymlinkDiffInfo) Summary

func (si SymlinkDiffInfo) Summary() string

func (SymlinkDiffInfo) TitleLabel

func (si SymlinkDiffInfo) TitleLabel() string

Jump to

Keyboard shortcuts

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