diff

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateTokens

func EstimateTokens(s string) int

EstimateTokens returns a rough token count from byte length using the chars/4 heuristic. Anthropic and OpenAI tokenizers vary, but chars/4 is a stable upper-bound estimate for English + code in v1; per-provider exact counts can replace this once the provider modules ship.

Types

type Diff

type Diff struct {
	Files  []FileDiff
	Origin git.Origin
	Args   map[string]string
}

func Filter

func Filter(d Diff, m *ignore.Matcher) Diff

func Parse

func Parse(input git.Diff) (Diff, error)

func (Diff) AddedLines

func (d Diff) AddedLines() int

func (Diff) DeletedLines

func (d Diff) DeletedLines() int

func (Diff) Empty

func (d Diff) Empty() bool

func (Diff) EstimateTokens

func (d Diff) EstimateTokens() int

func (Diff) FileCount

func (d Diff) FileCount() int

func (Diff) String

func (d Diff) String() string

type FileDiff

type FileDiff struct {
	Path    string
	OldPath string
	Mode    Mode
	Hunks   []Hunk
	Binary  bool
}

func (FileDiff) String

func (f FileDiff) String() string

type Hunk

type Hunk struct {
	OldStart int
	OldLines int
	NewStart int
	NewLines int
	Header   string
	Lines    []HunkLine
}

func (Hunk) String

func (h Hunk) String() string

type HunkLine

type HunkLine struct {
	Kind LineKind
	Text string
}

type LineKind

type LineKind int
const (
	LineContext LineKind = iota
	LineAdd
	LineDel
)

type Mode

type Mode int
const (
	ModeModified Mode = iota
	ModeAdded
	ModeDeleted
	ModeRenamed
	ModeCopied
)

func (Mode) String

func (m Mode) String() string

Jump to

Keyboard shortcuts

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