Documentation
¶
Overview ¶
Package diff is the parsed pr.diff that both location validation and the review interface read.
Index ¶
- func NextMarker(lines []ViewLine, from int) int
- func PrevMarker(lines []ViewLine, from int) int
- func WholeFile(path string, content []byte) []byte
- type Diff
- func (d *Diff) File(path string) *File
- func (d *Diff) FileView(path string, right, left map[int][]string) ([]ViewLine, error)
- func (d *Diff) HunkFor(path, side string, line int) (*File, *Hunk, error)
- func (d *Diff) HunkView(path, side string, line, startLine, context int) ([]ViewLine, error)
- func (d *Diff) ResolveHeading(path, text string) (startLine, line int, err error)
- func (d *Diff) Validate(path, side string, line, startLine int) error
- type File
- type Hunk
- type Kind
- type Line
- type Outline
- type ViewLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NextMarker ¶
NextMarker returns the index of the first marked line after from, wrapping to the start, or -1 when none is marked.
func PrevMarker ¶
PrevMarker returns the index of the last marked line before from, wrapping to the end, or -1 when none is marked.
Types ¶
type Diff ¶
type Diff struct {
Files []*File
// Outline is set only by add and edit, which load it when an input carries a heading anchor.
Outline Outline
// contains filtered or unexported fields
}
func (*Diff) File ¶
File finds a file by its new name, or by its old name when the file was deleted.
func (*Diff) FileView ¶
FileView returns every hunk of the file, each preceded by a separator. right and left map line numbers on each side to the finding ids anchored there; a context line exists on both sides and collects from both.
func (*Diff) HunkFor ¶
HunkFor finds the file and the hunk holding line on side, refusing like Validate when there is none.
func (*Diff) HunkView ¶
HunkView returns the hunk holding line on side, trimmed to context lines before the first and after the last anchored line. Anchored lines are those numbered startLine through line on side; startLine is 0 for one line.
func (*Diff) ResolveHeading ¶
ResolveHeading turns a heading anchor into the range of the one hunk that changes the heading's section, as Validate accepts it: startLine is 0 for a single line. It reads d.Outline, never the clone.
type File ¶
type Line ¶
Line numbers are zero on the side where the line does not exist: OldNum for Add, NewNum for Delete.