bridge.services.github package#

Public Interface#

This section documents user-facing interface of the bridge.services.github package (as defined in its __init__.py file).

Classes#

GitHubIngestor(owner, repo)

Ingest GitHub repository metadata via the GitHub REST API (raw JSON).

GitHubRepoProvider()

Provide GitHub repository operations.

GitHub integrations: async metadata ingestor and repository provider for forking, cloning, pushing, and opening pull requests.

class bridge.services.github.GitHubIngestor(owner, repo)[source]#

Bases: Ingestor

Ingest GitHub repository metadata via the GitHub REST API (raw JSON).

Parameters:
  • owner (str)

  • repo (str)

async fetch()[source]#

Fetch the full repository object (single endpoint).

Returns:

Raw JSON for the repository from GET /repos/{owner}/{repo}.

Return type:

dict

async fetch_github_pages()[source]#

Fetch the GitHub Pages information for the repository.

Returns:

Raw JSON for the GitHub Pages from GET /repos/{owner}/{repo}/pages.

Return type:

dict

async fetch_languages()[source]#

Fetch the programming languages used in the repository.

Returns:

Raw JSON for the languages from GET /repos/{owner}/{repo}/languages.

Return type:

dict | None

async fetch_latest_release()[source]#

Fetch the latest release (raw JSON) or return None if the repo has no releases.

Returns:

Latest release JSON, or None when GitHub returns 404 (no releases).

Return type:

dict | None

async fetch_readme()[source]#

Fetch the README content (decoded) or return None if not found.

Returns:

Decoded README content, or None if not found.

Return type:

str | None

async fetch_repo()[source]#

Fetch the full repository object (raw JSON).

Returns:

Raw JSON for the repository from GET /repos/{owner}/{repo}.

Return type:

dict

async get_user(username)[source]#

Fetch a GitHub user by username.

Parameters:

username (str) – GitHub username.

Returns:

Raw JSON for the user from GET /users/{username}.

Return type:

dict

class bridge.services.github.GitHubRepoProvider[source]#

Bases: RepoProvider

Provide GitHub repository operations.

apply_changes_and_push(repo_path, branch_name, file_changes)[source]#

Create a new branch from a local cloned repo, apply changes, and push.

Parameters:
  • repo_path (str) – Path to the local cloned GitHub repository.

  • branch_name (str) – Name of the new branch to create.

  • file_changes (dict) – Dictionary mapping file paths to their new content.

clone_context(repo_full_name)[source]#

Use context manager to clone a GitHub repo into a temp dir and delete it afterward.

Parameters:

repo_full_name (str) – Full name of the repository (e.g., “owner/repo”).

async create_issue(owner, repo, title, body='', labels=None, assignees=None)[source]#

Create a new issue on a GitHub repository.

Parameters:
  • owner (str) – GitHub user or organization that owns the repository.

  • repo (str) – Repository name.

  • title (str) – Title of the issue.

  • body (str, optional) – Description of the issue.

  • labels (list of str, optional) – List of label names to assign to the issue.

  • assignees (list of str, optional) – List of GitHub usernames to assign to the issue.

Returns:

JSON response from the GitHub API representing the created issue.

Return type:

dict

Raises:

HTTPError – If the API request fails.

async create_pull_request(owner, repo, title, body, head_branch, base_branch)[source]#

Create a pull request via GitHub REST API.

Parameters:
  • owner (str) – GitHub user or organization that owns the repository.

  • repo (str) – Repository name.

  • title (str) – Title of the pull request.

  • body (str) – Description of the pull request.

  • head_branch (str) – Name of the branch with the proposed changes.

  • base_branch (str, optional) – Target branch to merge into (default is ‘main’).

Returns:

JSON response from the GitHub API representing the created pull request.

Return type:

dict

Raises:

HTTPError – If the API request fails.

async fork(owner, repo, replace_existing=True, wait_ready=True, max_wait=20)[source]#

Fork a GitHub repository (or return an existing fork).

Parameters:
  • owner (str) – The owner of the repository to fork.

  • repo (str) – The name of the repository to fork.

  • replace_existing (bool) – Whether to delete an existing fork (if present) before creating a new one. Default is True.

  • wait_ready (bool) – Whether to wait until the fork is fully ready. Default is True.

  • max_wait (int) – Maximum number of seconds to wait for the fork to become ready. Default is 20.

Returns:

JSON metadata for the forked repository.

Return type:

dict

Raises:

HTTPError – If the fork operation fails.

Submodules#

github_auth

Helper for constructing GitHub API request headers using configured credentials.

github_ingestor

Async client for the GitHub API.

github_repo_provider

Repository provider for GitHub.

Dependencies diagram#

Each architecture diagram below visualizes the internal dependency structure of the bridge.services.github package. It shows how modules and subpackages within the package depend on each other, based on direct Python imports.

  • Packages are shown as purple rectangles

  • Modules are shown as pink rectangles

  • Arrows (A → B) indicate that A directly imports B

Each subpackage’s diagram focuses only on its own internal structure, it does not include imports to or from higher-level packages (those appear in the parent package’s diagram).

bridge package dependencies