gitdiff

package
v2.6.14 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLineChanged

func IsLineChanged(cl ChangedLines, absFile string, line int) bool

IsLineChanged reports whether absFile at the given line falls within any changed range in cl.

When line == 0 (position could not be determined), the function returns true to avoid filtering mutations at unknown positions.

When a file is present in cl but line falls outside every changed range, false is returned — the mutation targets an unchanged line. When a file is absent from cl entirely, all of its mutations are filtered.

Types

type ChangedLines

type ChangedLines map[string][]LineRange

ChangedLines maps relative file paths (from repo root, forward-slash separated) to the line ranges that were added or modified in the diff. A nil ChangedLines means "no filter" — all mutations are run.

func ParseChangedLines

func ParseChangedLines(base string) (ChangedLines, error)

ParseChangedLines runs `git diff --unified=0 <base>` and returns each modified file's changed line ranges. Deleted-only hunks (count == 0) are excluded — there is nothing to mutate on a removed line.

type LineRange

type LineRange struct{ Start, End int }

LineRange is an inclusive [Start, End] range of line numbers.

Jump to

Keyboard shortcuts

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