review.bot.gh_interface#
Contains functions to interface with GitHub.
Module Contents#
Functions#
|
Retrieve the filenames, status, and contents of files changed in a GitHub PR. |
Attributes#
- review.bot.gh_interface.LOG#
- review.bot.gh_interface.get_changed_files_and_contents(owner, repo, pull_number, gh_access_token=None)#
Retrieve the filenames, status, and contents of files changed in a GitHub PR.
- Parameters:
- owner
str The owner of the repository where the pull request was made.
- repo
str The name of the repository where the pull request was made.
- pull_number
int The number of the pull request to retrieve the changed files for.
- gh_access_token
str,optional GitHub token needed to communicate with the repository. By default,
None, which means it will try to read an existing env variable namedGITHUB_TOKEN.
- owner
- Returns:
list[dict]A list of dictionaries, where each dictionary represents a file that was changed in the pull request. The dictionary contains the following keys:
filename: str, the name of the file
status: str, the status of the file change (‘added’, ‘modified’, or ‘removed’)
file_text: str, the contents of the file as a string
- Raises:
RuntimeErrorIf an error occurs while fetching the file content.
Notes
This function uses the GitHub API to retrieve the list of changed files in a pull request, along with the contents of each changed file. It requires a GitHub access token with appropriate permissions to access the repository.