@@ -490,8 +490,6 @@ def dismiss_change_requests(
490490 repo ,
491491 pull_request_id ,
492492 warning_comment_prefix ,
493- auto_resolve_conversations ,
494- single_comment_markers ,
495493): # pylint: disable=too-many-arguments,too-many-positional-arguments
496494 """Dismissing stale Clang-Tidy requests for changes"""
497495
@@ -541,24 +539,23 @@ def dismiss_change_requests(
541539 # Avoid triggering abuse detection
542540 time .sleep (10 )
543541
544- if auto_resolve_conversations :
545- resolve_conversations (
546- github_token = github_token ,
547- repo = repo ,
548- pull_request_id = pull_request_id ,
549- github_api_timeout = github_api_timeout ,
550- single_comment_markers = single_comment_markers ,
551- )
552-
553542
543+ # pylint: disable=too-many-locals, too-many-arguments, too-many-positional-arguments
554544def conversation_threads_to_close (
555- repo , pr_number , github_token , github_api_timeout , single_comment_markers
545+ repo ,
546+ pr_number ,
547+ github_token ,
548+ github_api_timeout ,
549+ single_comment_markers ,
550+ comment_paths = None ,
556551):
557552 """Generator of unresolved conversation threads to close
558553
559554 Uses the GitHub GraphQL API to get conversation threads for the given PR.
560555 Then filters for unresolved threads and those that have been created by the action.
561556 """
557+ if comment_paths is None :
558+ comment_paths = set ()
562559
563560 repo_owner , repo_name = repo .split ("/" )
564561 query = """
@@ -577,6 +574,7 @@ def conversation_threads_to_close(
577574 author {
578575 login
579576 }
577+ path
580578 }
581579 }
582580 }
@@ -616,16 +614,19 @@ def conversation_threads_to_close(
616614
617615 # Iterate through review threads
618616 for thread in data ["data" ]["repository" ]["pullRequest" ]["reviewThreads" ]["nodes" ]:
617+ if thread ["isResolved" ]:
618+ continue
619619 for comment in thread ["comments" ]["nodes" ]:
620620 if (
621621 comment ["id" ]
622- and thread ["isResolved" ] is False
623622 # this actor here is somehow different from `github-actions[bot]`
624623 # which we get through the Rest API
625624 and comment ["author" ]["login" ] == "github-actions"
626625 and any (
627626 matcher .match (comment ["body" ].strip ()) for matcher in marker_matches
628627 )
628+ # if the file does not have any comment, we can safely close any conversation
629+ and comment ["path" ] not in comment_paths
629630 ):
630631 yield thread
631632 break
@@ -675,12 +676,23 @@ def _print_error_and_raise(msg):
675676 print ("Conversation closed successfully." )
676677
677678
679+ # pylint: disable=too-many-arguments, too-many-positional-arguments
678680def resolve_conversations (
679- github_token , repo , pull_request_id , github_api_timeout , single_comment_markers
681+ github_token ,
682+ repo ,
683+ pull_request_id ,
684+ github_api_timeout ,
685+ single_comment_markers ,
686+ comment_paths = None ,
680687):
681688 """Resolving stale conversations"""
682689 for thread in conversation_threads_to_close (
683- repo , pull_request_id , github_token , github_api_timeout , single_comment_markers
690+ repo ,
691+ pull_request_id ,
692+ github_token ,
693+ github_api_timeout ,
694+ single_comment_markers ,
695+ comment_paths = comment_paths ,
684696 ):
685697 close_conversation (
686698 thread_id = thread ["id" ],
@@ -806,9 +818,15 @@ def main():
806818 args .repository ,
807819 args .pull_request_id ,
808820 warning_comment_prefix = warning_comment_prefix ,
809- auto_resolve_conversations = args .auto_resolve_conversations == "true" ,
810- single_comment_markers = single_comment_markers ,
811821 )
822+ if args .auto_resolve_conversations == "true" :
823+ resolve_conversations (
824+ github_token = github_token ,
825+ repo = args .repository ,
826+ pull_request_id = args .pull_request_id ,
827+ github_api_timeout = github_api_timeout ,
828+ single_comment_markers = single_comment_markers ,
829+ )
812830 return 0
813831
814832 clang_tidy_fixes ["Diagnostics" ] = reorder_diagnostics (
@@ -823,6 +841,16 @@ def main():
823841 single_comment_markers = single_comment_markers ,
824842 )
825843 )
844+ if args .auto_resolve_conversations == "true" :
845+ comment_paths = set (comment ["path" ] for comment in review_comments )
846+ resolve_conversations (
847+ github_token = github_token ,
848+ repo = args .repository ,
849+ pull_request_id = args .pull_request_id ,
850+ github_api_timeout = github_api_timeout ,
851+ single_comment_markers = single_comment_markers ,
852+ comment_paths = comment_paths ,
853+ )
826854
827855 existing_pull_request_comments = list (
828856 get_pull_request_comments (
0 commit comments