Skip to content

angee.integrate_github.backend

GitHub REST implementation of the host-agnostic :class:VCSBackend.

Reads a GitHub remote over the REST API to populate the integrate inventory — listing repositories (by org), walking trees, reading blobs, resolving refs — and verifies inbound push webhooks. It never clones: git transport is the operator's job. Outbound calls go through the shared SSRF-pinned client (self.http, from :class:~angee.integrate.http.HttpClientMixin on :class:VCSBackend); the API base is admin-configured (api.github.com by default, a GHE host via VcsBridge.config), so the host is trusted rather than user-supplied per request.

MAX_REPO_PAGES

Hard cap on repository pages (~10k repos) so a pathological listing can't loop forever.

SEARCH_LIMIT

Repository search results returned for a typeahead query.

GitHubApiError

python
class GitHubApiError(Exception)

Raised when the GitHub REST API returns a non-success, non-404 status.

__init__

python
def __init__(message: str, *, status: int) -> None

Record the HTTP status for the failed request.

GitHubBackend

python
class GitHubBackend(VCSBackend)

A :class:VCSBackend that reads a GitHub remote over the REST API.

api_base

python
@property
def api_base() -> str

Return the REST API base URL (api.github.com or a configured GHE host).

ls_repos

python
def ls_repos(*, org: str = "") -> list[RepoDescriptor]

List every repository for org (or the authenticated account when blank).

Pages through the full listing: reconcile prunes repositories absent from this result, so a truncated first page would delete every repo past it. A short page (fewer than PER_PAGE) is the last; a hard cap bounds a pathological loop.

ls_tree

python
def ls_tree(repository: Any,
            *,
            ref: str,
            path: str,
            recursive: bool = False) -> list[TreeEntry]

List the tree under path at ref via the git-trees API.

cat_file

python
def cat_file(repository: Any, *, ref: str, path: str) -> bytes

Return the bytes of one blob via the contents API; raise if absent or a tree.

rev_parse

python
def rev_parse(repository: Any, ref: str) -> str

Resolve ref to a commit oid via the commits API.

search_repos

python
def search_repos(query: str, *, org: str = "") -> list[RepoDescriptor]

Return repositories whose name matches query via the search API (typeahead).

get_repo

python
def get_repo(name: str) -> RepoDescriptor

Return one repository by owner/repo name; raise FileNotFoundError if absent.

verify_webhook

python
def verify_webhook(vcs_bridge: Any, request: Any) -> bool

Verify an inbound push webhook's HMAC-SHA256 signature against the secret.

Released under the AGPL-3.0 License.