Documentation
¶
Index ¶
- Variables
- func IsGitRepo() bool
- func ResolveGitRef(ref string) (string, error)
- type BinaryDiff
- type DetailResult
- type DiffStatus
- type DirSummary
- type FileKind
- type GitCommitInfo
- type GitMeta
- type ImageDiff
- type Line
- type Mode
- type Node
- type PlistChange
- type PlistDiff
- type Result
- type SectionChange
- type Summary
- type SymbolChange
- type TextDiff
- type TextHunk
Constants ¶
This section is empty.
Variables ¶
var ErrBinaryContent = fmt.Errorf("file contains binary content")
ErrBinaryContent indicates that a file classified as text actually contains binary data and should not be diffed as text.
Functions ¶
func IsGitRepo ¶ added in v0.6.0
func IsGitRepo() bool
IsGitRepo returns true if the current working directory is inside a git repository.
func ResolveGitRef ¶ added in v0.6.0
ResolveGitRef validates and resolves a git ref to its full SHA.
Types ¶
type BinaryDiff ¶
type BinaryDiff struct {
Symbols []SymbolChange `json:"symbols"`
Sections []SectionChange `json:"sections"`
}
BinaryDiff contains symbol and section differences between two Mach-O binaries.
type DetailResult ¶
type DetailResult struct {
Kind FileKind `json:"kind"`
Plist *PlistDiff `json:"plist,omitempty"`
Binary *BinaryDiff `json:"binary,omitempty"`
Text *TextDiff `json:"text,omitempty"`
Image *ImageDiff `json:"image,omitempty"`
Dir *DirSummary `json:"dir,omitempty"`
}
DetailResult holds an on-demand detail diff for a single node.
type DiffStatus ¶
type DiffStatus int
DiffStatus represents the diff status of a node.
const ( Unchanged DiffStatus = iota Added Removed Modified )
func (DiffStatus) MarshalJSON ¶
func (s DiffStatus) MarshalJSON() ([]byte, error)
func (DiffStatus) String ¶
func (s DiffStatus) String() string
type DirSummary ¶
type DirSummary struct {
TotalFiles int `json:"total_files"`
Added int `json:"added"`
Removed int `json:"removed"`
Modified int `json:"modified"`
Unchanged int `json:"unchanged"`
SizeDelta int64 `json:"size_delta"`
}
DirSummary holds aggregate statistics for a directory node.
type FileKind ¶
type FileKind int
FileKind represents the detected type of a file.
func (FileKind) MarshalJSON ¶
type GitCommitInfo ¶ added in v0.6.0
type GitCommitInfo struct {
SHA string `json:"sha"`
Subject string `json:"subject"`
Body string `json:"body,omitempty"`
Author string `json:"author"`
Date string `json:"date"`
Ref string `json:"ref"` // original ref (branch name, tag, HEAD, etc.)
Remote string `json:"remote,omitempty"`
}
GitCommitInfo holds metadata for a single git commit.
func (*GitCommitInfo) CommitURL ¶ added in v0.6.0
func (c *GitCommitInfo) CommitURL() string
CommitURL returns the web URL for viewing a commit, or empty if unavailable.
func (*GitCommitInfo) PRNumber ¶ added in v0.6.0
func (c *GitCommitInfo) PRNumber() string
PRNumber extracts a pull request number from the commit subject if it follows the squash-merge "(#1234)" convention used by GitHub.
func (*GitCommitInfo) PRURL ¶ added in v0.6.0
func (c *GitCommitInfo) PRURL() string
PRURL returns the web URL for viewing the pull request, or empty if unavailable.
type GitMeta ¶ added in v0.6.0
type GitMeta struct {
CommitA *GitCommitInfo `json:"commit_a,omitempty"`
CommitB *GitCommitInfo `json:"commit_b,omitempty"`
}
GitMeta holds git-specific metadata for the comparison.
func BuildGitMeta ¶ added in v0.6.0
BuildGitMeta constructs GitMeta for two refs.
type ImageDiff ¶ added in v0.5.0
type ImageDiff struct {
WidthA int `json:"width_a"`
HeightA int `json:"height_a"`
WidthB int `json:"width_b"`
HeightB int `json:"height_b"`
FormatA string `json:"format_a"`
FormatB string `json:"format_b"`
ColorModelA string `json:"color_model_a"`
ColorModelB string `json:"color_model_b"`
// Pixel diff stats (only populated when dimensions match).
PixelsChanged int `json:"pixels_changed"`
PixelsTotal int `json:"pixels_total"`
ChangePercent float64 `json:"change_percent"`
// Bounding box of changed region.
ChangeBounds image.Rectangle `json:"change_bounds"`
// Decoded images for TUI rendering (not serialized).
ImageA image.Image `json:"-"`
ImageB image.Image `json:"-"`
// DiffMask highlights changed pixels (nil when dimensions differ).
DiffMask image.Image `json:"-"`
}
ImageDiff holds the result of comparing two images.
type Line ¶
type Line struct {
Kind string `json:"kind"` // "context", "added", "removed"
Content string `json:"content"`
}
Line represents a single line in a diff hunk.
type Node ¶
type Node struct {
Name string `json:"name"`
Path string `json:"path"`
Status DiffStatus `json:"status"`
Kind FileKind `json:"kind"`
IsDir bool `json:"is_dir"`
SizeA int64 `json:"size_a"`
SizeB int64 `json:"size_b"`
Children []*Node `json:"children,omitempty"`
}
Node represents a single entry in the diff tree.
type PlistChange ¶
type PlistChange struct {
KeyPath string `json:"key_path"`
Status DiffStatus `json:"status"`
ValueA string `json:"value_a,omitempty"`
ValueB string `json:"value_b,omitempty"`
}
PlistChange represents a single key-path change in a plist diff.
type PlistDiff ¶
type PlistDiff struct {
Changes []PlistChange `json:"changes"`
}
PlistDiff contains key-level changes between two plists.
type Result ¶
type Result struct {
PathA string `json:"path_a"`
PathB string `json:"path_b"`
Mode Mode `json:"mode"`
Root *Node `json:"root"`
Summary Summary `json:"summary"`
Git *GitMeta `json:"git,omitempty"`
}
Result is the top-level output of a comparison.
func Compare ¶
Compare runs the appropriate comparison for the given paths and mode. If mode is empty, it is auto-detected from the inputs.
func CompareGitWorkTree ¶ added in v0.6.0
CompareGitWorkTree builds a diff tree of uncommitted changes against HEAD.
type SectionChange ¶
type SectionChange struct {
Segment string `json:"segment"`
Section string `json:"section"`
SizeA int64 `json:"size_a"`
SizeB int64 `json:"size_b"`
}
SectionChange represents a size change in a Mach-O section.
type Summary ¶
type Summary struct {
Added int `json:"added"`
Removed int `json:"removed"`
Modified int `json:"modified"`
Unchanged int `json:"unchanged"`
SizeDelta int64 `json:"size_delta"`
}
Summary aggregates diff statistics.
func ComputeSummary ¶
ComputeSummary walks the tree and computes aggregate statistics.
type SymbolChange ¶
type SymbolChange struct {
Name string `json:"name"`
Status DiffStatus `json:"status"`
}
SymbolChange represents a symbol that was added or removed.