Documentation
¶
Overview ¶
Package github implements the SourceReader port over the GitHub Contents API. It is read-only: it issues a single authenticated GET per file and never performs a write request.
Index ¶
- type GitHub
- func (g *GitHub) Fetch(ctx context.Context, repo, ref string) (rootDir string, cleanup func(), err error)
- func (g *GitHub) FindByBranch(ctx context.Context, repo, branch string) (ports.PullRequestRef, bool, error)
- func (g *GitHub) ListDir(ctx context.Context, repo, ref, dir string) ([]string, error)
- func (g *GitHub) PRStatus(ctx context.Context, repo string, number int) (ports.PRStatus, error)
- func (g *GitHub) ReadFile(ctx context.Context, repo, ref, path string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitHub ¶
type GitHub struct {
// contains filtered or unexported fields
}
func NewSourceReader ¶
NewSourceReader builds a read-only GitHub source reader. baseURL is the API root (https://api.github.com in prod; a stub in dev/e2e).
func (*GitHub) Fetch ¶
func (g *GitHub) Fetch(ctx context.Context, repo, ref string) (rootDir string, cleanup func(), err error)
Fetch downloads the tarball of repo at ref via GET {base}/repos/{repo}/tarball/{ref} — the same base URL and PAT as ReadFile — and extracts it into a fresh temporary directory.
func (*GitHub) FindByBranch ¶
func (g *GitHub) FindByBranch(ctx context.Context, repo, branch string) (ports.PullRequestRef, bool, error)
FindByBranch looks up repo's pull request(s) with the given head branch via a single read-only GET, and returns the first match. GitHub's list endpoint returns at most one open PR per branch (it forbids opening a second), so a single result covers the normal case; state=all also surfaces one already closed since creation, which the reconciler records and lets the ordinary open-PR sweep carry to its terminal outcome next pass.
func (*GitHub) ListDir ¶
ListDir returns the repo-relative paths of the files directly under dir at ref, using the GitHub Contents API directory listing. Sub-directories are omitted. A 404 (directory absent) → ErrSourceNotFound.
func (*GitHub) PRStatus ¶
PRStatus returns the current state of repo's pull request #number via a single read-only GET. Every non-2xx response (including 404) is an error so the caller leaves the proposal untouched and retries on the next pass.