Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StripPathPrefix ¶
StripPathPrefix removes a configured prefix from a file path, making it relative to the repository root.
Types ¶
type BlameLine ¶
type BlameLine struct {
Line int `json:"line"`
CommitHash string `json:"commit_hash"`
Author string `json:"author"`
Date time.Time `json:"date"`
Message string `json:"message"`
}
BlameLine represents a single line's blame information.
type Commit ¶
type Commit struct {
Hash string `json:"hash"`
Author string `json:"author"`
Message string `json:"message"`
Date time.Time `json:"date"`
FilesChanged []string `json:"files_changed"`
}
Commit represents a Git commit.
type Config ¶
type Config struct {
Provider string `yaml:"provider" json:"provider"`
Token string `yaml:"token" json:"token"`
Repos []RepoMapping `yaml:"repos" json:"repos"`
}
Config holds SCM integration configuration.
type GitHubProvider ¶
type GitHubProvider struct {
// contains filtered or unexported fields
}
GitHubProvider implements SCMProvider using the GitHub REST API.
func NewGitHubProvider ¶
func NewGitHubProvider(token string) *GitHubProvider
NewGitHubProvider creates a new GitHub provider with the given personal access token.
func (*GitHubProvider) GetBlame ¶
func (g *GitHubProvider) GetBlame(repo, path string, startLine, endLine int) ([]BlameLine, error)
GetBlame retrieves blame information for a range of lines in a file. It prefers GitHub's GraphQL blame API for precise per-line attribution and falls back to the REST commits approximation (all lines attributed to the most recent commit) when GraphQL is unavailable — no token, an API error, or an empty result.
func (*GitHubProvider) GetFileContent ¶
func (g *GitHubProvider) GetFileContent(repo, path, ref string) (string, error)
GetFileContent retrieves the content of a file from a GitHub repository.
func (*GitHubProvider) ListRecentCommits ¶
func (g *GitHubProvider) ListRecentCommits(repo string, limit int) ([]Commit, error)
ListRecentCommits returns the most recent commits for a repository.
type RepoMapping ¶
type RepoMapping struct {
Owner string `yaml:"owner" json:"owner"`
Repo string `yaml:"repo" json:"repo"`
PathPrefix string `yaml:"path_prefix" json:"path_prefix"` // strip from stack trace paths
}
RepoMapping maps a configured repository to path-strip rules.
type SCMProvider ¶
type SCMProvider interface {
GetFileContent(repo, path, ref string) (string, error)
GetBlame(repo, path string, startLine, endLine int) ([]BlameLine, error)
ListRecentCommits(repo string, limit int) ([]Commit, error)
}
SCMProvider is the interface for source code management integrations.
type SourceContext ¶
type SourceContext struct {
Lines []SourceLine `json:"lines"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
FilePath string `json:"file_path"`
Repo string `json:"repo"`
CommitHash string `json:"commit_hash"`
}
SourceContext holds surrounding code lines for a file:line reference.
func GetSourceContext ¶
func GetSourceContext(provider SCMProvider, repo, filePath string, errorLine, contextLines int) (*SourceContext, error)
GetSourceContext retrieves source code lines around a file:line reference.
type SourceLine ¶
type SourceLine struct {
Number int `json:"number"`
Content string `json:"content"`
IsError bool `json:"is_error"` // true for the error line
}
SourceLine is a single line of source code with metadata.
type StackFrame ¶
StackFrame represents a parsed frame from a stack trace.
func ParseStackTrace ¶
func ParseStackTrace(stack string) []StackFrame
ParseStackTrace extracts file paths and line numbers from a stack trace.
type SuspectCommit ¶
type SuspectCommit struct {
Commit
Score float64 `json:"score"` // higher = more likely
ErrorFiles []string `json:"error_files"` // files from the stack trace this commit touched
ErrorLines int `json:"error_lines"` // how many error lines this commit touched
Reason string `json:"reason"` // human-readable explanation
}
SuspectCommit is a commit suspected of causing an error.
func FindSuspectCommits ¶
func FindSuspectCommits(provider SCMProvider, stack string, repos []RepoMapping) ([]SuspectCommit, error)
FindSuspectCommits analyzes blame data for stack trace files and identifies commits that are likely responsible for the error.