mass_driver.forges.github

Githubas Forge. Using the github lib if available

Module Contents

Classes

GithubBaseForge

Base for github forge

GithubPersonalForge

Github API wrapper for personal user token use, capable of creating/getting PRs

GithubAppForge

Create PRs on Github as a Github App, not user

Functions

detect_github_repo

Find the github remote from a cloneable URL

detect_pr_info

Detect a PR’s repo and number

API

class mass_driver.forges.github.GithubBaseForge[source]

Bases: mass_driver.models.forge.Forge

Base for github forge

_github_api: github.Github = None
create_pr(forge_repo_url: str, base_branch: mass_driver.models.forge.BranchName, head_branch: mass_driver.models.forge.BranchName, pr_title: str, pr_body: str, draft: bool)[source]

Send a PR, with msg body, to forge_repo for given branch of repo_path

get_pr_status(pr_url: str) str[source]

Get the status of a single given PR, used as key to group PRs by status

property pr_statuses: list[str]

List possible PR statuses that will be returned by get_pr_status.

List is sorted from most complete (accepted-and-merged) to least completed (not merged, not review-approved, has merge-conflicts).

The returned list’s ordering is used by the view-pr mass-driver command to show the PRs by status, from most completed to least completed.

_get_pr(forge_repo: str, pr_id: str)[source]

Get the PR by ID on forge_repo

class mass_driver.forges.github.GithubPersonalForge(**data)[source]

Bases: mass_driver.forges.github.GithubBaseForge

Github API wrapper for personal user token use, capable of creating/getting PRs

Reliance on pygithub means only able to deliver personal user token PRs, no Github app authentication.

Initialization

Log in to Github first

token: pydantic.SecretStr = None

Github personal access token

class mass_driver.forges.github.GithubAppForge(**data)[source]

Bases: mass_driver.forges.github.GithubBaseForge

Create PRs on Github as a Github App, not user

Initialization

Log in to Github first

app_id: pydantic.SecretStr = None
app_private_key: pydantic.SecretStr = None
app_installation_id: int = None
mass_driver.forges.github.detect_github_repo(remote_url: str)[source]

Find the github remote from a cloneable URL

detect_github_repo(“git@github.com:OverkillGuy/sphinx-needs-test.git”) ‘OverkillGuy/sphinx-needs-test’

mass_driver.forges.github.detect_pr_info(pr_url: str) tuple[str, str, str][source]

Detect a PR’s repo and number

detect_pr_info(“https://github.com/OverkillGuy/sphinx-needs-test/pull/1”) (‘OverkillGuy’, ‘sphinx-needs-test’, ‘1’)