Documentation
¶
Overview ¶
Package parse wraps go-gitdiff. We expose a minimal struct surface (`Diff` / `File` / `Hunk` / `Line`) so the renderer doesn't depend on the upstream type names — keeps the option to swap libraries later if go-gitdiff evolves in an uncomfortable direction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diff ¶
type Diff struct {
Files []File
}
Diff is the top-level result of parsing a unified-diff stream.
func Parse ¶
Parse consumes a unified diff stream into the typed shape. The readSrc may be a bytes.Reader or any other io.Reader; we don't enforce a max-size cap here — caller decides.
func ParseBytes ¶
ParseBytes is a convenience for the common case of having the patch as a single buffer.
type File ¶
type File struct {
OldPath string
NewPath string
OldMode string
NewMode string
IsBinary bool
IsNew bool
IsDelete bool
IsRename bool
IsCopy bool
Hunks []Hunk
// Score is the rename/copy similarity (0–100) when IsRename or IsCopy.
Score int
// IsTooLarge marks files past the per-file render threshold; the
// renderer emits a "too large" placeholder + expander link rather
// than the full hunks.
IsTooLarge bool
// SizeBytes is the rough cost of this file's hunks (sum of line
// content). Used to drive truncation decisions.
SizeBytes int
}
File is one changed path. OldPath / NewPath differ on rename/copy; they're equal on a normal modify. IsBinary, IsRename, IsCopy, IsNew, IsDelete summarize the extended-header flags so renderers don't reach into the upstream types.
type Hunk ¶
type Hunk struct {
OldStart int
OldLines int
NewStart int
NewLines int
Section string // text after the closing `@@` (function name etc.)
Lines []Line
}
Hunk is one `@@ -X,Y +A,B @@` block.