Documentation
¶
Overview ¶
Package githubgh implements the GitHub provider adapter by shelling out to the `gh` CLI. Lands in M2.
Index ¶
- func Supports(raw string) bool
- type Adapter
- func (a *Adapter) Fetch(ctx context.Context, rawURL string) (*review.ReviewInput, error)
- func (a *Adapter) FetchLinkedIssues(ctx context.Context, target review.ReviewTarget) ([]review.IssueContext, []string, error)
- func (a *Adapter) List(ctx context.Context, repo provider.RepoCoord) ([]provider.PRSummary, error)
- func (a *Adapter) Preflight(ctx context.Context) error
- func (a *Adapter) PreflightList(ctx context.Context) error
- func (a *Adapter) Supports(rawURL string) bool
- type Preflight
- type PullRequestRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter fetches GitHub pull request data via the `gh` CLI.
func New ¶
New constructs an Adapter. Passing nil uses provider.DefaultRunner and a default Preflight that calls exec.LookPath. Tests that need to substitute LookPath can build an Adapter literal directly.
func (*Adapter) Fetch ¶
Fetch retrieves PR metadata and the unified diff, then returns a normalized ReviewInput. The diff is parsed via internal/diff to surface classification errors early, before the model is invoked.
func (*Adapter) FetchLinkedIssues ¶ added in v0.2.0
func (a *Adapter) FetchLinkedIssues(ctx context.Context, target review.ReviewTarget) ([]review.IssueContext, []string, error)
FetchLinkedIssues resolves the issues this PR formally closes (closingIssuesReferences) and reads each one's title/body via `gh issue view`. diffsmith-144.
Failure contract (review.LinkedIssueFetcher): a failure of the closing-refs query is total (returned as err — the caller surfaces it as one note and proceeds with no criteria); a failure on an individual issue is non-fatal (the issue is dropped and a note is appended), so one inaccessible cross-repo issue can't sink the rest.
func (*Adapter) List ¶
List enumerates open PRs for the repo and enriches each row with comment count, resolved/unresolved thread counts, and human commenters, all in a single GraphQL call.
func (*Adapter) Preflight ¶
Preflight verifies gh is on PATH and authenticated before any fetch. New always wires a.preflight, and Adapter's fields are unexported so no zero-value literal can escape the package — a defensive nil-init here would be dead code.
func (*Adapter) PreflightList ¶
PreflightList verifies gh is authenticated before listing PRs.
type Preflight ¶
Preflight verifies the runtime environment is ready to fetch GitHub PRs.
Per docs/architecture.md § Pre-Flight Checks, the model is never invoked when these fail; the user sees an actionable message instead of a stack trace from `os/exec`.
func NewPreflight ¶
NewPreflight builds a Preflight with sensible defaults. Tests inject fakes; production code calls NewPreflight(nil, nil).
type PullRequestRef ¶
type PullRequestRef struct {
Owner string
Repo string
Number int
URL string // canonical form: https://github.com/<owner>/<repo>/pull/<number>
}
PullRequestRef identifies a GitHub pull request parsed from a URL.
func ParseURL ¶
func ParseURL(raw string) (*PullRequestRef, error)
ParseURL extracts a PullRequestRef from a GitHub pull request URL.
Accepts the canonical form and any sub-path under it (e.g. /files, /commits), query strings, and trailing slashes. Rejects URLs that are not pull requests, not GitHub, or not HTTPS.