diff --git a/src/response_agent.py b/src/response_agent.py index eeb4bfc..a117014 100644 --- a/src/response_agent.py +++ b/src/response_agent.py @@ -25,6 +25,7 @@ import os from src.git_utils import ( + get_issue_comments, get_github_client, get_repository, write_issue_response, @@ -102,6 +103,19 @@ def tab_print(x): print('\t' + str(x)) +def filter_comments(comments: List) -> List: + """ + Filter out comments containing "Codecov Report". + + Args: + comments: List of comments to filter. + + Returns: + Filtered list of comments. + """ + return [comment for comment in comments if "Codecov Report" not in comment.body] + + def extract_urls_from_issue(issue: Issue) -> List[str]: """ Extract URLs from issue body and comments @@ -120,7 +134,9 @@ def extract_urls_from_issue(issue: Issue) -> List[str]: urls.extend(extractor.find_urls(issue_body)) # Extract from comments - for comment in get_issue_comments(issue): + comments = get_issue_comments(issue) + comments = filter_comments(comments) + for comment in comments: comment_body = comment.body or "" urls.extend(extractor.find_urls(comment_body)) diff --git a/src/triggers.py b/src/triggers.py index a0ef1cb..2606b64 100644 --- a/src/triggers.py +++ b/src/triggers.py @@ -6,6 +6,7 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) # noqa: E501 from github import Issue from src.git_utils import get_issue_comments, has_linked_pr, get_linked_pr +from src.response_agent import filter_comments def has_blech_bot_tag(issue: Issue) -> bool: @@ -32,6 +33,7 @@ def has_generate_edit_command_trigger(issue: Issue) -> bool: True if the trigger phrase is found in any comment """ comments = get_issue_comments(issue) + comments = filter_comments(comments) return any("[ generate_edit_command ]" in comment.body for comment in comments)