github

package
v0.0.0-...-c5ce160 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

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

func NewSourceReader(baseURL, token string, hc *http.Client) *GitHub

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

func (g *GitHub) ListDir(ctx context.Context, repo, ref, dir string) ([]string, error)

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

func (g *GitHub) PRStatus(ctx context.Context, repo string, number int) (ports.PRStatus, error)

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.

func (*GitHub) ReadFile

func (g *GitHub) ReadFile(ctx context.Context, repo, ref, path string) (string, error)

ReadFile returns the raw text of repo/path at ref. 404 → ErrSourceNotFound. Returns an error if the response body exceeds maxSourceBytes or cannot be read fully, so the caller never receives silently truncated content.

Jump to

Keyboard shortcuts

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