Documentation
¶
Overview ¶
Package git provides git-context enrichment and remote-forge integration. See ../REFACTOR_PLAN.md.
Index ¶
- func DetectProvider(projectDir string) (string, string, string)
- func FormatCIStatus(status *CIStatus) string
- func FormatIssues(issues []GitIssue) string
- func FormatPRs(prs []PullRequest) string
- type BlameLine
- type CICheck
- type CIStatus
- type CommitInfo
- type Context
- type FileInfo
- type GitContext
- func (gc *GitContext) BuildContextForFile(path string) string
- func (gc *GitContext) BuildContextForSession() string
- func (gc *GitContext) GetBlame(path string, startLine, endLine int) ([]BlameLine, error)
- func (gc *GitContext) GetBranch() (string, error)
- func (gc *GitContext) GetDiffSummary() (string, error)
- func (gc *GitContext) GetFileInfo(path string) (*GitFileInfo, error)
- func (gc *GitContext) GetRecentChanges(days int) ([]CommitInfo, error)
- func (gc *GitContext) GetRelatedFiles(path string) ([]string, error)
- func (gc *GitContext) GetUncommitted() ([]string, error)
- func (gc *GitContext) IsRecentlyModified(path string, within time.Duration) bool
- type GitFileInfo
- type GitIssue
- type GitProvider
- func (gp *GitProvider) CreateIssue(title, body string, labels []string) (*GitIssue, error)
- func (gp *GitProvider) CreatePR(title, body, branch, baseBranch string) (*PullRequest, error)
- func (gp *GitProvider) GetCIStatus(branch string) (*CIStatus, error)
- func (gp *GitProvider) GetIssue(number int) (*GitIssue, error)
- func (gp *GitProvider) GetReviewComments(prNumber int) ([]string, error)
- func (gp *GitProvider) ListIssues(state string, limit int) ([]GitIssue, error)
- func (gp *GitProvider) ListPRs(state string, limit int) ([]PullRequest, error)
- type Issue
- type Provider
- type PullRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectProvider ¶
DetectProvider parses .git/config or uses gh to detect provider/owner/repo.
func FormatCIStatus ¶
FormatCIStatus formats a CIStatus for terminal display.
func FormatIssues ¶
FormatIssues formats a slice of issues for terminal display.
func FormatPRs ¶
func FormatPRs(prs []PullRequest) string
FormatPRs formats a slice of pull requests for terminal display.
Types ¶
type CIStatus ¶
type CIStatus struct {
State string // "success", "failure", "pending"
Checks []CICheck
URL string
}
CIStatus represents the overall CI/CD status for a branch.
type CommitInfo ¶
CommitInfo represents a single git commit.
type Context ¶
type Context = GitContext
Context wraps a local git repo and exposes file/commit/blame queries.
func NewContext ¶
NewContext returns a git Context bound to the given working directory.
type GitContext ¶
type GitContext struct {
RepoDir string
// contains filtered or unexported fields
}
GitContext provides git-aware context enrichment for files and sessions.
func NewGitContext ¶
func NewGitContext(repoDir string) *GitContext
NewGitContext creates a new GitContext for the given repo directory.
func (*GitContext) BuildContextForFile ¶
func (gc *GitContext) BuildContextForFile(path string) string
BuildContextForFile gathers all git context for a file and formats it as a readable string.
func (*GitContext) BuildContextForSession ¶
func (gc *GitContext) BuildContextForSession() string
BuildContextForSession returns overall repository context.
func (*GitContext) GetBlame ¶
func (gc *GitContext) GetBlame(path string, startLine, endLine int) ([]BlameLine, error)
GetBlame returns blame info for lines startLine to endLine of the given file.
func (*GitContext) GetBranch ¶
func (gc *GitContext) GetBranch() (string, error)
GetBranch returns the current branch name.
func (*GitContext) GetDiffSummary ¶
func (gc *GitContext) GetDiffSummary() (string, error)
GetDiffSummary summarizes current uncommitted changes.
func (*GitContext) GetFileInfo ¶
func (gc *GitContext) GetFileInfo(path string) (*GitFileInfo, error)
GetFileInfo returns git metadata for a file, using cache if available.
func (*GitContext) GetRecentChanges ¶
func (gc *GitContext) GetRecentChanges(days int) ([]CommitInfo, error)
GetRecentChanges returns commits from the last N days.
func (*GitContext) GetRelatedFiles ¶
func (gc *GitContext) GetRelatedFiles(path string) ([]string, error)
GetRelatedFiles finds files frequently modified together with the given file.
func (*GitContext) GetUncommitted ¶
func (gc *GitContext) GetUncommitted() ([]string, error)
GetUncommitted returns a list of modified or staged files.
func (*GitContext) IsRecentlyModified ¶
func (gc *GitContext) IsRecentlyModified(path string, within time.Duration) bool
IsRecentlyModified checks if the file was modified within the given duration.
type GitFileInfo ¶
type GitFileInfo struct {
Path string
LastAuthor string
LastCommitMsg string
LastModified time.Time
CommitCount int
Contributors []string
RecentCommits []CommitInfo
Blame []BlameLine
}
GitFileInfo holds git metadata about a specific file.
type GitIssue ¶
type GitIssue struct {
Number int
Title string
Body string
Labels []string
State string
Author string
CreatedAt time.Time
URL string
}
GitIssue represents a git provider issue.
type GitProvider ¶
type GitProvider struct {
Type string // "github", "gitlab", "bitbucket"
Token string
Owner string
Repo string
BaseURL string
// contains filtered or unexported fields
}
GitProvider integrates with GitHub/GitLab/Bitbucket APIs for issue management, PR creation, and CI status checking via CLI tools.
func NewGitProvider ¶
func NewGitProvider(providerType, token, owner, repo string) *GitProvider
NewGitProvider creates a new GitProvider with the given configuration.
func (*GitProvider) CreateIssue ¶
func (gp *GitProvider) CreateIssue(title, body string, labels []string) (*GitIssue, error)
CreateIssue creates a new issue with the given title, body, and labels.
func (*GitProvider) CreatePR ¶
func (gp *GitProvider) CreatePR(title, body, branch, baseBranch string) (*PullRequest, error)
CreatePR creates a new pull request.
func (*GitProvider) GetCIStatus ¶
func (gp *GitProvider) GetCIStatus(branch string) (*CIStatus, error)
GetCIStatus returns the CI status for the given branch.
func (*GitProvider) GetIssue ¶
func (gp *GitProvider) GetIssue(number int) (*GitIssue, error)
GetIssue returns a single issue by number.
func (*GitProvider) GetReviewComments ¶
func (gp *GitProvider) GetReviewComments(prNumber int) ([]string, error)
GetReviewComments returns review comments for a PR.
func (*GitProvider) ListIssues ¶
func (gp *GitProvider) ListIssues(state string, limit int) ([]GitIssue, error)
ListIssues returns issues matching the given state and limit.
func (*GitProvider) ListPRs ¶
func (gp *GitProvider) ListPRs(state string, limit int) ([]PullRequest, error)
ListPRs returns pull requests matching the given state and limit.
type Provider ¶
type Provider = GitProvider
Provider talks to a remote forge (GitHub, GitLab, ...) for issues, PRs, CI.
func NewProvider ¶
NewProvider returns a forge provider client.