github

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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.

View Source
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

func API(cwd string, stdin []byte, args ...string) ([]byte, error)

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

func ParseRemote(url string) (owner, name string, err error)

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

func PlainName(s string) bool

PlainName reports whether s is an owner or repository name abcd will put into an API path.

func Run

func Run(cwd string, stdin []byte, args ...string) ([]byte, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL