Documentation
¶
Overview ¶
Package github wraps go-github with the narrow surface open_team_pr needs. The interface exists because there are two implementations: the real go-github wrapper and the fake used in tools tests.
Index ¶
Constants ¶
const ( Owner = "osinfra-io" Repo = "pt-logos" Base = "main" )
Repo is the hard-coded write target for tools that target pt-logos (open_team_pr, the four read tools, etc). Tools that write to other repos under the same org pass repo as a parameter via the *InRepo methods below.
const ( RepoCorpus = "pt-corpus" RepoPneuma = "pt-pneuma" RepoEkklesiaDocs = "pt-ekklesia-docs" )
Repos for cross-repo helpers; kept as named constants so callers do not hard-code repository names at use sites.
Variables ¶
This section is empty.
Functions ¶
func IsConflict ¶
IsConflict reports whether err is a 409 or 422 response from the GitHub API, indicating a concurrent-write reconcile point.
Types ¶
type Client ¶
type Client interface {
GetRef(ctx context.Context, branch string) (sha string, exists bool, err error)
CreateRef(ctx context.Context, branch, fromSHA string) error
UpdateRef(ctx context.Context, branch, toSHA string, force bool) error
DeleteRef(ctx context.Context, branch string) error
CompareCommits(ctx context.Context, base, head string) (CompareStatus, error)
GetFile(ctx context.Context, path, ref string) (content []byte, blobSHA string, exists bool, err error)
ListDir(ctx context.Context, path, ref string) (names []string, exists bool, err error)
// GetFileInRepo reads a single file from a sibling repo under
// osinfra-io. Used by the helpers renderers (render_corpus_helpers,
// render_pneuma_helpers) which fetch helpers.tofu from pt-corpus and
// pt-pneuma respectively, and by open_team_docs_pr / get_team's
// docs_pages probe against pt-ekklesia-docs.
GetFileInRepo(ctx context.Context, repo, path, ref string) (content []byte, blobSHA string, exists bool, err error)
// ListDirInRepo lists files in a directory of a sibling repo under
// osinfra-io. Used by get_team to enumerate a team's docs pages.
ListDirInRepo(ctx context.Context, repo, path, ref string) (names []string, exists bool, err error)
// Cross-repo write surface used by open_team_docs_pr (writes to
// pt-ekklesia-docs). Mirrors the pt-logos-only methods above so the
// same transaction shape works for any repo under osinfra-io.
GetRefInRepo(ctx context.Context, repo, branch string) (sha string, exists bool, err error)
CreateRefInRepo(ctx context.Context, repo, branch, fromSHA string) error
UpdateRefInRepo(ctx context.Context, repo, branch, toSHA string, force bool) error
DeleteRefInRepo(ctx context.Context, repo, branch string) error
CompareCommitsInRepo(ctx context.Context, repo, base, head string) (CompareStatus, error)
CreateOrUpdateFileInRepo(ctx context.Context, repo, path, branch, blobSHA string, content []byte, message string) (commitSHA string, err error)
ListOpenPRsInRepo(ctx context.Context, repo, head, base string) ([]PullRequest, error)
CreatePRInRepo(ctx context.Context, repo, head, base, title, body string) (PullRequest, error)
CreateOrUpdateFile(ctx context.Context, path, branch, blobSHA string, content []byte, message string) (commitSHA string, err error)
ListOpenPRs(ctx context.Context, head, base string) ([]PullRequest, error)
CreatePR(ctx context.Context, head, base, title, body string) (PullRequest, error)
AddLabels(ctx context.Context, prNumber int, labels []string) error
AddLabelsInRepo(ctx context.Context, repo string, prNumber int, labels []string) error
}
Client is the narrow GitHub surface open_team_pr depends on. Two implementations exist (this is what justifies the interface under the "no interfaces until two impls" rule): goClient (production, wraps go-github) and the in-memory fake in open_team_pr_test.go.
func New ¶
New returns a Client backed by go-github authenticated with the given pre-minted token. The token may be a PAT, an installation token, or the output of `gh auth token` — the server doesn't care; how it's minted is the deployment's responsibility (see the README's Configuration section for required permissions).
type CompareStatus ¶
type CompareStatus string
CompareStatus is the result of comparing a branch against the base. Mirrors the GitHub Compare API status string.
const ( StatusIdentical CompareStatus = "identical" StatusAhead CompareStatus = "ahead" StatusBehind CompareStatus = "behind" StatusDiverged CompareStatus = "diverged" )
type PullRequest ¶
PullRequest is the minimal shape open_team_pr needs from a PR.