52 lines
2.2 KiB
Python
52 lines
2.2 KiB
Python
"""
|
|
adapters/vcs/github.py
|
|
GitHub VCS adapter — Phase 2 stub.
|
|
|
|
TODO (Phase 2):
|
|
- Implement create_branch() using PyGithub or gh CLI subprocess.
|
|
- Implement commit() — stage files and push via git subprocess or API.
|
|
- Implement create_pr() using GitHub REST API (POST /repos/{owner}/{repo}/pulls).
|
|
- Implement get_pr_status() using GET /repos/{owner}/{repo}/pulls/{pull_number}.
|
|
- Read repo and credentials from config/team.yaml and environment (GITHUB_TOKEN).
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from adapters.base.vcs import VCSAdapter
|
|
|
|
|
|
class GitHubAdapter(VCSAdapter):
|
|
"""
|
|
VCS adapter for GitHub repositories.
|
|
|
|
Expects environment variable GITHUB_TOKEN and config values:
|
|
run.repo — SSH or HTTPS clone URL
|
|
run.base_branch — default base branch (e.g. "main")
|
|
"""
|
|
|
|
def __init__(self, config: dict) -> None:
|
|
# TODO (Phase 2): Accept loaded team.yaml config dict.
|
|
# Extract GITHUB_TOKEN from environment.
|
|
# Parse owner/repo from config.run.repo.
|
|
raise NotImplementedError("GitHubAdapter.__init__ is not yet implemented.")
|
|
|
|
def create_branch(self, name: str) -> None:
|
|
# TODO (Phase 2): Create branch via GitHub API or local git subprocess.
|
|
# Use config.run.base_branch as the branch point.
|
|
raise NotImplementedError("GitHubAdapter.create_branch is not yet implemented.")
|
|
|
|
def commit(self, files: list[str], message: str) -> str:
|
|
# TODO (Phase 2): Stage files (git add), create commit (git commit), push.
|
|
# Return the resulting commit SHA.
|
|
raise NotImplementedError("GitHubAdapter.commit is not yet implemented.")
|
|
|
|
def create_pr(self, title: str, body: str, head: str, base: str) -> str:
|
|
# TODO (Phase 2): POST to GitHub API /repos/{owner}/{repo}/pulls.
|
|
# Return the HTML URL of the created PR.
|
|
raise NotImplementedError("GitHubAdapter.create_pr is not yet implemented.")
|
|
|
|
def get_pr_status(self, pr_id: str) -> str:
|
|
# TODO (Phase 2): GET /repos/{owner}/{repo}/pulls/{number}.
|
|
# Map GitHub PR state ("open", "closed") + merged flag to
|
|
# our schema: "open" | "merged" | "closed".
|
|
raise NotImplementedError("GitHubAdapter.get_pr_status is not yet implemented.")
|