Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAddedLines ¶
GetAddedLines extracts all added lines from a diff hunk
func GetModifiedContentFromDiffHunk ¶
GetModifiedContentFromDiffHunk applies a diff hunk to original content
func GetRemovedLines ¶
GetRemovedLines extracts all removed lines from a diff hunk
func GetZeroBased ¶
GetZeroBased converts 1-based line numbers to 0-based Special case: 0 stays 0 (used for empty files)
Types ¶
type DiffChangeType ¶
type DiffChangeType int
DiffChangeType represents the type of change in a diff line
const ( Context DiffChangeType = iota Add Delete Control )
type DiffHunk ¶
type DiffHunk struct {
OldStart int // Starting line in old file (1-based)
OldLines int // Number of lines in old file
NewStart int // Starting line in new file (1-based)
NewLines int // Number of lines in new file
Lines []*DiffLine // The actual diff lines
}
DiffHunk represents a hunk in a unified diff
func ParseDiffHunk ¶
ParseDiffHunk parses a unified diff hunk into a structured format Expected format: @@ -oldStart,oldLines +newStart,newLines @@ context line +added line -removed line
func ParsePatch ¶
ParsePatch parses a complete unified diff patch into multiple hunks
type DiffLine ¶
type DiffLine struct {
Type DiffChangeType
OldLineNumber int // 1-based, -1 if not applicable
NewLineNumber int // 1-based, -1 if not applicable
Text string // Line content without the prefix (+, -, or space)
PositionInHunk int // Position within the hunk (0-based)
}
DiffLine represents a single line in a diff
func GetDiffLineByPosition ¶
GetDiffLineByPosition finds a diff line by its position in the overall diff diffLineNumber is 1-based (GitHub's position)