Documentation
¶
Index ¶
- func ApplyHunk(base string, h Hunk) string
- func BaseContent(repoRoot string, staged bool, file string) (string, error)
- func RawNewFileDiff(repoRoot, file string) (string, error)
- func RawUnifiedDiff(repoRoot string, staged bool, file string) (string, error)
- type DiffOpts
- type Engine
- type FileDiff
- type Hunk
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyHunk ¶
ApplyHunk applies a single hunk to the base file content, producing a new file with only that hunk's changes. This gives difftastic a full file for tree-sitter parsing.
func BaseContent ¶
BaseContent retrieves the base file content for diffing. For unstaged diffs: the index version (git show :file). For staged diffs: the HEAD version (git show HEAD:file).
func RawNewFileDiff ¶
RawNewFileDiff generates a unified diff for an untracked file by comparing /dev/null against the file.
Types ¶
type Engine ¶
type Engine interface {
Diff(ctx context.Context, repoRoot, file string, opts DiffOpts) (string, error)
DiffCommit(ctx context.Context, repoRoot, base, target string, color bool, width int) (string, error)
DiffHunks(ctx context.Context, hunks []Hunk, filename, baseContent string, color bool, width int) []string
Name() string
}
type FileDiff ¶
func ParseUnifiedDiff ¶
Click to show internal directories.
Click to hide internal directories.