bridge.services.github.github_repo_provider module#
Repository provider for GitHub. Forks repos, clones to a temp directory, applies file changes, pushes branches, and creates pull requests via the GitHub API.
- class bridge.services.github.github_repo_provider.GitHubRepoProvider[source]#
Bases:
RepoProviderProvide 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.