Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thread-comments are not exclusive to github-actions bot #53

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 5 additions & 14 deletions cpp_linter/rest_api/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def __init__(self) -> None:
self.event_payload = json.loads(
Path(event_path).read_text(encoding="utf-8")
)
#: The user's account ID number. Defaults to the generic bot's ID.
self.user_id = 41898282

def set_exit_code(
self,
Expand Down Expand Up @@ -233,9 +231,7 @@ def make_annotations(
for note in concern.notes:
if note.filename == file.name:
output = "::{} ".format(
"notice"
if note.severity.startswith("note")
else note.severity
"notice" if note.severity.startswith("note") else note.severity
)
output += "file={file},line={line},title={file}:{line}:".format(
file=file.name, line=note.line
Expand Down Expand Up @@ -319,13 +315,9 @@ def remove_bot_comments(
page += 1
count -= len(comments)
for comment in comments:
# only search for comments from the user's ID and
# whose comment body begins with a specific html comment
if (
int(comment["user"]["id"]) == self.user_id
# the specific html comment is our action's name
and comment["body"].startswith("<!-- cpp linter action -->")
):
# only search for comments that begin with a specific html comment.
# the specific html comment is our action's name
if cast(str, comment["body"]).startswith("<!-- cpp linter action -->"):
logger.debug(
"comment id %d from user %s (%d)",
comment["id"],
Expand All @@ -339,8 +331,7 @@ def remove_bot_comments(
# use saved comment_url if not None else current comment url
url = comment_url or comment["url"]
response_buffer = self.session.delete(
url,
headers=self.make_headers(),
url, headers=self.make_headers()
)
logger.info(
"Got %d from DELETE %s",
Expand Down