Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseGitRange ¶
ParseGitRange parses a Git range specification into base and head references. Supports formats like "main..feature", "HEAD~1", or single references. Returns "HEAD~1" and "HEAD" as defaults for empty input.
Types ¶
type DiffData ¶
type DiffData struct {
FilePath string `json:"file_path"`
OldFilePath string `json:"old_file_path,omitempty"`
NewFilePath string `json:"new_file_path,omitempty"`
IsNew bool `json:"is_new"`
IsDeleted bool `json:"is_deleted"`
IsRenamed bool `json:"is_renamed"`
Hunks []DiffHunk `json:"hunks"`
}
DiffData represents structured information about a file diff. It contains metadata about the file changes and parsed diff hunks.
func ParseDiff ¶
ParseDiff parses a unified diff string into structured DiffData. The input should be in standard unified diff format with @@ hunk headers.
func (*DiffData) FormatForReview ¶
FormatForReview formats the diff data into a human-readable string for code review. The output includes file status, change summary, and formatted diff hunks.
func (*DiffData) GetAddedLines ¶
GetAddedLines returns all lines that were added in this diff. Useful for analyzing what new code was introduced.
func (*DiffData) GetContextLines ¶
GetContextLines returns all unchanged context lines from the diff. Context lines provide surrounding code for better understanding.
func (*DiffData) GetRemovedLines ¶
GetRemovedLines returns all lines that were removed in this diff. Useful for analyzing what code was deleted.
type DiffHunk ¶
type DiffHunk struct {
OldStart int `json:"old_start"`
OldCount int `json:"old_count"`
NewStart int `json:"new_start"`
NewCount int `json:"new_count"`
Header string `json:"header"`
Lines []DiffLine `json:"lines"`
}
DiffHunk represents a contiguous section of changes in a diff. Each hunk contains line-by-line changes with context.
type DiffLine ¶
type DiffLine struct {
Type DiffLineType `json:"type"`
Content string `json:"content"`
OldNum int `json:"old_num,omitempty"`
NewNum int `json:"new_num,omitempty"`
}
DiffLine represents a single line in a diff with its type and position. Lines can be added, removed, context, or metadata.
type DiffLineType ¶
type DiffLineType string
DiffLineType represents the type of a diff line (added, removed, context, etc.).
const ( DiffLineAdded DiffLineType = "added" DiffLineRemoved DiffLineType = "removed" DiffLineContext DiffLineType = "context" DiffLineNoNewline DiffLineType = "no_newline" )
type GitClient ¶
type GitClient struct {
// contains filtered or unexported fields
}
GitClient provides an interface for Git operations needed for code review. It wraps go-git functionality to provide diff and commit information.
func NewGitClient ¶
NewGitClient creates a new GitClient instance for the current directory. Returns an error if the current directory is not a Git repository.
func (*GitClient) GetChangedFiles ¶
GetChangedFiles returns a list of files that changed between two Git references. References can be commit hashes, branch names, or symbolic refs like HEAD.
func (*GitClient) GetFileDiff ¶
GetFileDiff returns the raw diff text for a specific file between two references. The returned string contains the unified diff format suitable for review.