Documentation
¶
Overview ¶
PR-number resolution for `gitl review pr/N` (§ post-MVP). The GitHub CLI (`gh`) resolves a PR number into base/head SHAs; the diff itself is then computed locally by gitlog.Runner (triple-dot base...head, like GitHub), so the whole shaping pipeline (exclude_globs, truncation, stats) stays identical across review modes.
Package cli wires up the gitl command tree (cobra) and shared scaffolding: persistent flags, viper-backed config loading, and slog setup.
One file per command: root.go (this scaffold), version.go, review.go, changelog.go, digest.go (see docs/TECHNICAL_PLAN.md §6, §9, §10).
Index ¶
- func Execute(ctx context.Context, args []string) error
- func RunDigestCore(ctx context.Context, cfg *config.Config, opts DigestOptions) (render.DigestArtifact, error)
- func RunReviewCore(ctx context.Context, cfg *config.Config, src diffSource, opts ReviewOptions) (render.Artifact, error)
- type DigestOptions
- type PRRef
- type PRResolver
- type ReviewOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
Execute runs the gitl command tree with the given context and args. It returns a non-nil error to signal a non-zero exit code; the error is printed to stderr here so main stays thin.
func RunDigestCore ¶ added in v0.5.0
func RunDigestCore(ctx context.Context, cfg *config.Config, opts DigestOptions) (render.DigestArtifact, error)
RunDigestCore executes the (possibly multi-repo) digest pipeline without any cobra dependency and without writing the result anywhere: it resolves the repository list, collects per-repo digests concurrently, and returns the final artifact ready for the render package (md|text|json) or the TUI.
func RunReviewCore ¶ added in v0.5.0
func RunReviewCore(ctx context.Context, cfg *config.Config, src diffSource, opts ReviewOptions) (render.Artifact, error)
RunReviewCore executes the full review pipeline for one resolved diffSource without any cobra dependency and without writing the result anywhere: diff shaping, prompt build, cache lookup, cost guard, provider selection, the buffered provider call, and cache store. It returns the final artifact ready for the render package (md|text|json).
CLI-only concerns intentionally live in runReview instead: --dry-run (prints an estimate, produces no artifact), terminal token streaming, rendering, and the --fail-on exit-code gate.
Types ¶
type DigestOptions ¶ added in v0.5.0
type DigestOptions struct {
// Days is the size of the activity window in days (the --days flag).
// Must be > 0.
Days int
// Repos, when non-empty, is the explicit repository path list (the --repos
// flag): it replaces cfg digest.repos wholesale (§10.4). Entries are
// trimmed, empty ones skipped, relative paths made absolute. When empty,
// cfg.Digest.Repos is used, falling back to the current directory.
Repos []string
}
DigestOptions carries the per-run digest parameters. Deliberately plain Go types only — no *cobra.Command, no *pflag.FlagSet — so non-CLI callers can fill it directly (config.Load with Options{Flags: nil} still applies defaults→file→env).
type PRRef ¶ added in v0.4.0
type PRRef struct {
BaseSHA string
HeadSHA string
HeadRef string // head branch name, for diagnostics
BaseRefName string // base branch name (e.g. "main") — fetched by name, more robust than a bare SHA
URL string // full PR URL — identifies the PR's repository for remote-name resolution
// CrossRepo marks a PR from a fork. Not an error: `git fetch <remote>
// pull/N/head` works for forks too, so PR review handles them
// transparently.
CrossRepo bool
}
PRRef is the resolved base/head SHA pair for a pull request.
type PRResolver ¶ added in v0.4.0
PRResolver resolves a PR number into SHAs. The production ghResolver shells out to `gh`; tests substitute a fake, so no test ever talks to GitHub.
type ReviewOptions ¶ added in v0.5.0
type ReviewOptions struct {
// NoCache skips the on-disk LLM response cache entirely (the --no-cache
// flag): no lookup, no store.
NoCache bool
// ErrOut receives user-facing warnings (the offline-mode notice, cost-guard
// warnings). The CLI passes its stderr; nil discards them.
ErrOut io.Writer
}
ReviewOptions carries the per-run review parameters that are not part of the merged config. Deliberately plain Go types only — no *cobra.Command, no *pflag.FlagSet — so non-CLI callers can fill it directly (config.Load with Options{Flags: nil} still applies defaults→file→env).