GitHub Repository¶
This is the GitHub Repository API to do all things to do with GitHub repositories.
Repository API¶
- class ghastoolkit.Repository(owner: str, repo: str, reference: str | None = None, branch: str | None = None, path: str | None = None, pr_number: int | None = None, __prinfo__: dict | None = None, sha: str | None = None, clone_path: str | None = None, repo_token: str | None = None, is_github_app_token: bool = False)¶
GitHub Repository.
- __str__() str ¶
To String.
- branch: str | None = None¶
Branch / Tab name
- clone(path: str | None = None, clobber: bool = False, depth: int | None = None)¶
Clone Repository based on url.
path: str - if left None, it will create a tmp folder for you.
- clone_path: str | None = None¶
Clone Path
- property clone_url: str¶
Repository clone URL.
- createPullRequestComment(comment_body: str) None ¶
Create a new Pull Request comment.
- display() str ¶
Display the repository as a string.
- getFile(path: str) str ¶
Get a path relative from the base of the cloned repository.
- getPullRequestComments() list[dict[str, int | str]] ¶
Get list of Pull Request comments.
- getPullRequestCommits() list[str] ¶
Get list of Pull Request commits.
- getPullRequestInfo() dict ¶
Get information for the current Pull Request.
https://docs.github.com/en/enterprise-cloud@latest/rest/pulls/pulls#get-a-pull-request
- getPullRequestNumber() int ¶
Get Pull Request Number / ID.
- gitsha() str ¶
Get the current Git SHA.
- isInPullRequest() bool ¶
Check if the current reference is in a Pull Request.
- is_github_app_token: bool = False¶
Whether the token is a GitHub App Token
- owner: str¶
Owner
- static parseRepository(name: str) Repository ¶
Parse the repository name into a Repository object.
- Samples:
owner/repo
owner/repo:relative/path/in/repo
owner/repo/relative/path/in/repo
owner/repo:relative/path/in/repo@branch
- path: str | None = None¶
Path inside the repository
- pr_number: int | None = None¶
Pull Request Number (if in a PR)
- reference: str | None = None¶
Reference (refs/heads/main)
- repo: str¶
Repository name
- repo_token: str | None = None¶
Repository Access Token
- sha: str | None = None¶
Git SHA
- updatePullRequestComment(comment_id: int, comment_body: str) None ¶
Update an existing Pull Request comment.