rest_api.github_api
¶
A module that holds any github-specific interactions. Most of this functionality is designed around GitHub’s REST API.
Seealso
- class cpp_linter.rest_api.github_api.GithubApiClient[source]¶
A class that describes the API used to interact with Github’s REST API.
- api_url¶
The base domain for the REST API
- repo¶
The
owner
/repository
name.
- event_name¶
The triggering event type’s name
- sha¶
The HEAD commit’s SHA
- debug_enabled¶
A flag that describes if debug logs are enabled.
- pull_request¶
The pull request number for the event (if applicable).
-
set_exit_code(checks_failed: int, format_checks_failed: int | None =
None
, tidy_checks_failed: int | None =None
)[source]¶ Set the action’s output values and shows them in the log output.
- get_list_of_changed_files(file_filter: FileFilter, lines_changed_only: int) list[FileObj] [source]¶
Fetch a list of the event’s changed files.
- Parameters:¶
- file_filter: FileFilter¶
A
FileFilter
obj to filter files.- lines_changed_only: int¶
A value that dictates what file changes to focus on.
- verify_files_are_present(files: list[FileObj]) None [source]¶
Download the files if not present.
Hint
This function assumes the working directory is the root of the invoking repository. If files are not found, then they are downloaded to the working directory. This is bad for files with the same name from different folders.
-
make_headers(use_diff: bool =
False
) dict[str, str] [source]¶ Create a
dict
for use in REST API headers.
- post_feedback(files: list[FileObj], args: Args, clang_versions: ClangVersions)[source]¶
Post action’s results using REST API.
- make_annotations(files: list[FileObj], style: str) None [source]¶
Use github log commands to make annotations from clang-format and clang-tidy output.
- update_comment(comment: str, comments_url: str, no_lgtm: bool, update_only: bool, is_lgtm: bool)[source]¶
Updates the comment for an existing comment or posts a new comment if
update_only
isFalse
.- Parameters:¶
- comment: str¶
The Comment to post.
- comments_url: str¶
The URL used to fetch the comments.
- no_lgtm: bool¶
A flag to control if a “Looks Good To Me” comment should be posted. If this is
True
, then an outdated bot comment will still be deleted.- update_only: bool¶
A flag that describes if the outdated bot comment should only be updated (instead of replaced).
- is_lgtm: bool¶
A flag the describes if the comment being posted is essentially a “Looks Good To Me” comment.
- remove_bot_comments(comments_url: str, delete: bool) str | None [source]¶
Traverse the list of comments made by a specific user and remove all.
- static create_review_comments(files: list[FileObj], tidy_tool: bool, summary_only: bool, review_comments: ReviewComments)[source]¶
Creates a batch of comments for a specific clang tool’s PR review.
- Parameters:¶
- files: list[FileObj]¶
The list of files to traverse.
- tidy_tool: bool¶
A flag to indicate if the suggestions should originate from clang-tidy.
- summary_only: bool¶
A flag to indicate if only the review summary is desired.
- review_comments: ReviewComments¶
An object (passed by reference) that is used to store the results.