Documentation
¶
Overview ¶
Package pr resolves PR state for a list of (repo, branch) pairs by shelling out to `gh`. It is the source-of-truth in v2 for whether a worktree's branch is open / merged / closed; the per-Phase Status field on the on-disk sandbox record is just a 60-second cache.
The package is deliberately small: one entry point, one shape of answer, and one shim seam (the GHBin variable) for tests. Anything fancier (auth probing, multi-account orchestration) belongs in `gh` itself.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GHBin = "gh"
GHBin is the binary runGH execs. A variable, deliberately not an env knob: tests (here and in internal/cli) swap in a fixture shim that prints canned JSON, and no public surface exists to point clawk at a different gh — that's what PATH is for.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Branch string `json:"branch"`
State State `json:"state"`
Number int `json:"number,omitempty"`
URL string `json:"url,omitempty"`
}
Result describes the canonical PR for one (repo, branch). When State is StateUnknown, Number is zero and the rest of the fields are undefined.
func Resolve ¶
Resolve queries `gh pr list` once for the given repo and returns one Result per branch the caller asked about. Branches with no PR are returned with State=StateUnknown rather than omitted, so callers can iterate the slice they passed in lock-step with the response.
gh requires a working directory inside a git repo (it reads the remote URL from there). repo must therefore be the path to a git checkout, not a remote URL.
One process per repo: PR listing is cheap on the GitHub side (single REST call) and avoiding O(branches) processes keeps a 10-branch sandbox snappy.