Documentation
¶
Overview ¶
Package gitlabglab implements the GitLab provider adapter by shelling out to the `glab` CLI. Lands in M6.
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 MergeRequestRef
- type Preflight
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter fetches GitLab merge request data via the `glab` 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 use NewWithLookPath.
func NewWithLookPath ¶
NewWithLookPath constructs an Adapter with explicit run + lookPath injection so cross-package tests (e.g. internal/app/) can build a fully hermetic Adapter that needs neither real `glab` on PATH nor real network. Passing nil for either falls back to defaults (provider.DefaultRunner, exec.LookPath).
func (*Adapter) Fetch ¶
Fetch retrieves MR metadata and the unified diff via glab, then returns a normalized ReviewInput with Host=review.HostGitLab. 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 MR closes via the closes_issues API. diffsmith-144.
One call returns title + description for every closing issue, so there is no per-issue failure mode: a failure of the single API call is total (returned as err for the caller to surface as one note and proceed with no criteria), matching review.LinkedIssueFetcher's contract.
func (*Adapter) List ¶
List enumerates open MRs for the repo via `glab mr list`. Omitting `--opened` (deprecated as of glab v1.x) inherits the default "open" behavior without triggering the deprecation warning that glab writes to stdout, mixed with the JSON.
After the initial listing, List fetches per-MR discussion data bounded-concurrently (cap 6) to populate enrichment fields. A per-MR discussions fetch failure marks that row Enriched=false with base fields intact; all other rows continue to be enriched.
func (*Adapter) PreflightList ¶
PreflightList verifies glab is authenticated before listing MRs.
type MergeRequestRef ¶
type MergeRequestRef struct {
ProjectPath string
Number int
URL string // canonical: https://gitlab.com/<project-path>/-/merge_requests/<number>
RepoURL string // https://gitlab.com/<project-path>
}
MergeRequestRef identifies a GitLab merge request parsed from a URL. ProjectPath is the full URL-path namespace+project (e.g. "group/project" or "group/sub/project" for nested groups); the adapter splits it at the last slash to populate review.ReviewTarget.Owner/Repo. RepoURL is the project URL passed to `glab -R`.
func ParseURL ¶
func ParseURL(raw string) (*MergeRequestRef, error)
ParseURL extracts a MergeRequestRef from a GitLab merge request URL.
Accepts the canonical form and any sub-path under it (e.g. /diffs, /commits), query strings, and trailing slashes. Supports nested groups of any depth (gitlab.com/<group>/<sub>/.../<project>). Rejects URLs that are not MRs, not gitlab.com, or not HTTPS — self-hosted GitLab is a V1.x concern, not V1.
type Preflight ¶
Preflight verifies the runtime environment is ready to fetch GitLab MRs.
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`. Mirrors internal/provider/githubgh.Preflight; the only intentional divergence is the auth-failure error string ordering (actionable text first, %w wrap at the tail) so the contiguous acceptance-required substring is preserved without sacrificing errors.Is/Unwrap on the underlying transport error.
func NewPreflight ¶
NewPreflight builds a Preflight with sensible defaults. Tests inject fakes; production code calls NewPreflight(nil, nil).