Documentation
¶
Overview ¶
Package github implements the vcs.Provider interface for GitHub using the gh CLI.
Index ¶
- func ParseRepoURL(url string) (owner, repo string, err error)
- type Provider
- func (p *Provider) CheckStatus(ctx context.Context, worktreePath string, prNumber int) (*vcs.PRStatus, error)
- func (p *Provider) CheckStatusLight(ctx context.Context, worktreePath string, prNumber int) (*vcs.PRStatus, error)
- func (p *Provider) CreatePR(ctx context.Context, params vcs.CreateParams) (*vcs.PR, error)
- func (p *Provider) FetchCILogs(ctx context.Context, worktreePath string, checks []vcs.CICheck) (map[string]string, error)
- func (p *Provider) FetchPRChecks(ctx context.Context, worktreePath string, prNumber int) (string, []vcs.CICheck, error)
- func (p *Provider) FetchPendingReviewRequests(ctx context.Context, worktreePath string, prNumber int) ([]vcs.ReviewRequest, error)
- func (p *Provider) FetchReviewComments(ctx context.Context, worktreePath string, prNumber int) ([]vcs.ReviewComment, error)
- func (p *Provider) FetchUnresolvedThreadCount(ctx context.Context, worktreePath string, prNumber int) (int, error)
- func (p *Provider) GetPRByHeadBranch(ctx context.Context, worktreePath, branch string) (*vcs.OpenPR, error)
- func (p *Provider) GetRepoOwnerAndName(ctx context.Context, worktreePath string) (owner, repo string, err error)
- func (p *Provider) ListOpenPRs(ctx context.Context, worktreePath string) ([]vcs.OpenPR, error)
- func (p *Provider) MergePR(ctx context.Context, worktreePath string, prNumber int, strategy string) error
- func (p *Provider) Platform() vcs.Platform
- func (p *Provider) ResolveThread(ctx context.Context, worktreePath string, threadID string) error
- func (p *Provider) ThreadIDByBodyHeader(ctx context.Context, worktreePath string, prNumber int, header string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRepoURL ¶
ParseRepoURL parses a git remote URL into owner and repository name.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements vcs.Provider for GitHub using the gh CLI.
func New ¶
New creates a GitHub VCS provider. The state DB is optional (may be nil); when non-nil, CreatePR records the PR and runs an initial mergeability check.
func (*Provider) CheckStatus ¶
func (p *Provider) CheckStatus(ctx context.Context, worktreePath string, prNumber int) (*vcs.PRStatus, error)
CheckStatus gets the full status of a PR via gh pr view and GraphQL.
func (*Provider) CheckStatusLight ¶
func (p *Provider) CheckStatusLight(ctx context.Context, worktreePath string, prNumber int) (*vcs.PRStatus, error)
CheckStatusLight gets the review-request, mergeable, and head-SHA state of a PR without fetching unresolved thread counts (which requires expensive GraphQL pagination). headRefOid is included so callers (e.g. the manual assay_rerun handler) can record the run against the actual head; omitting it left HeadSHA empty and Assay re-runs spawned workers with head="".
func (*Provider) CreatePR ¶
CreatePR creates a pull request using the gh CLI and optionally records it in the state DB when a DB was provided at construction time.
func (*Provider) FetchCILogs ¶
func (p *Provider) FetchCILogs(ctx context.Context, worktreePath string, checks []vcs.CICheck) (map[string]string, error)
FetchCILogs fetches CI logs for failing checks from GitHub Actions. Returns a map of check name → log output.
func (*Provider) FetchPRChecks ¶
func (p *Provider) FetchPRChecks(ctx context.Context, worktreePath string, prNumber int) (string, []vcs.CICheck, error)
FetchPRChecks returns the raw output of `gh pr checks` and the parsed failing checks for a PR.
func (*Provider) FetchPendingReviewRequests ¶
func (p *Provider) FetchPendingReviewRequests(ctx context.Context, worktreePath string, prNumber int) ([]vcs.ReviewRequest, error)
FetchPendingReviewRequests uses GraphQL to check for pending review requests, including Bot reviewers (e.g., copilot-pull-request-reviewer) that the gh CLI's --json reviewRequests field does not serialize.
func (*Provider) FetchReviewComments ¶
func (p *Provider) FetchReviewComments(ctx context.Context, worktreePath string, prNumber int) ([]vcs.ReviewComment, error)
FetchReviewComments returns review comments and unresolved threads on a PR via GraphQL and the gh CLI.
func (*Provider) FetchUnresolvedThreadCount ¶
func (p *Provider) FetchUnresolvedThreadCount(ctx context.Context, worktreePath string, prNumber int) (int, error)
FetchUnresolvedThreadCount uses the GraphQL API to count unresolved review threads.
func (*Provider) GetPRByHeadBranch ¶ added in v0.16.0
func (p *Provider) GetPRByHeadBranch(ctx context.Context, worktreePath, branch string) (*vcs.OpenPR, error)
GetPRByHeadBranch returns the open PR whose head branch matches the given branch name, or nil if no matching PR is found. Uses --head filtering so only the matching PR is returned regardless of how many open PRs exist.
func (*Provider) GetRepoOwnerAndName ¶
func (p *Provider) GetRepoOwnerAndName(ctx context.Context, worktreePath string) (owner, repo string, err error)
GetRepoOwnerAndName extracts the owner and repository name from git remote origin.
func (*Provider) ListOpenPRs ¶
ListOpenPRs returns all open PRs in the repository.
func (*Provider) MergePR ¶
func (p *Provider) MergePR(ctx context.Context, worktreePath string, prNumber int, strategy string) error
MergePR merges a PR using the gh CLI with the specified strategy. Valid strategies: "squash", "merge", "rebase". Defaults to "squash" if empty.
func (*Provider) ResolveThread ¶
ResolveThread resolves a review thread on a GitHub PR via GraphQL.
func (*Provider) ThreadIDByBodyHeader ¶ added in v0.20.0
func (p *Provider) ThreadIDByBodyHeader(ctx context.Context, worktreePath string, prNumber int, header string) (string, error)
ThreadIDByBodyHeader returns the GraphQL node ID of the first review thread on the PR whose top comment body contains the given header marker (for example an "<!-- assay-hash: … -->" line). It returns "" (no error) when no thread matches. Assay uses this to locate the thread it previously opened for a finding so the thread can be resolved once the finding is gone.