Documentation
¶
Overview ¶
Package github is abcd's one door to GitHub's API: the `gh` runner every forge read and write goes through, and the parser that turns an origin URL into the only repository a request may name (spc-2610120557432880, step 1; one-canonical-primitive). It was lifted out of internal/core/ahoy, whose remote verbs, and the site verb through them, were its only callers, so the embargo verbs share it rather than growing a second runner.
The call goes through `gh` rather than a raw HTTP client on purpose: it inherits the caller's own authenticated identity, so abcd never handles a token and a write is made by the person who invoked it, which is what adr-44's "no uninvited remote mutation" rests on.
Index ¶
Constants ¶
const Host = "github.com"
Host is the API host every request names EXPLICITLY. Without it `gh api` picks its host from GH_HOST, or from whichever single host the caller's gh is authenticated to, so the github.com-only rule ParseRemote enforces would constrain the PATH while the environment chose the ENDPOINT. An ambient GH_HOST (a repo direnv file, a CI job, an agent harness) would then send an authenticated write, with whatever credential gh holds for that host, to a machine the origin URL never named.
const MaxOutputBytes = 1 << 20
MaxOutputBytes caps what is read back from `gh`, stdout and stderr each (trust boundary): the response is remote-controlled, and an unbounded read into memory is the shape a hostile or broken endpoint exploits.
const Timeout = 30 * time.Second
Timeout bounds each `gh` call. A subprocess reading from the network with no bound is a verb that hangs a session indefinitely on a stalled connection.
Variables ¶
This section is empty.
Functions ¶
func API ¶
API runs `gh api --hostname github.com <args...>` under cwd: Run with the host named by construction, so no caller can forget it.
func ParseRemote ¶
ParseRemote splits a github.com remote URL into owner and repository. It accepts the forms git itself writes (`https://github.com/owner/repo[.git]`, `git@github.com:owner/repo[.git]`, `ssh://git@github.com/owner/repo`) and refuses everything else, without echoing the URL's segments: the URL is repo-controlled input, and a refusal is output like any other.
func PlainName ¶
PlainName reports whether s is an owner or repository name abcd will put into an API path.
func Run ¶
Run executes one `gh` subcommand under cwd and returns its bounded stdout. The environment is passed through unchanged; scrubbing it would blind gh to the credentials that make the caller the actor. A missing gh is refused with the tool registry's explanation (itd-63): what gh is, that these verbs require it, and the exact install step.
Types ¶
This section is empty.