@@ -305,18 +305,36 @@ def handle_review_event(self, data):
305
305
review_id = int (review_id [1 ])
306
306
307
307
actually_a_review = False
308
+ found_comment = False
308
309
for page in range (1 , 100 ): # Assume no more than 10k comments
309
310
comment_list_url = f"https://api.github.com/repos/{ repo_name } /pulls/{ pr ['number' ]} /comments?per_page=100&page={ page } "
310
311
comment_list = requests .get (comment_list_url , headers = self .headers )
311
312
comment_list .raise_for_status ()
312
313
comments = comment_list .json ()
313
314
for comment in comments :
314
315
if comment ["pull_request_review_id" ] == review_id :
316
+ found_comment = True
315
317
if comment .get ("in_reply_to_id" ) is None :
316
318
actually_a_review = True
317
319
if len (comments ) < 100 :
318
320
break
319
- if not actually_a_review :
321
+ for page in range (1 , 100 ):
322
+ review_list_url = f"https://api.github.com/repos/{ repo_name } /pulls/{ pr ['number' ]} /reviews?per_page=100&page={ page } "
323
+ review_list = requests .get (review_list_url , headers = self .headers )
324
+ review_list .raise_for_status ()
325
+ reviews = review_list .json ()
326
+ for review in reviews :
327
+ if review ["id" ] == review_id :
328
+ if len (review ["body" ]) != 0 :
329
+ actually_a_review = True
330
+ if len (comments ) < 100 :
331
+ break
332
+ if found_comment and not actually_a_review :
333
+ # Github treats any comment on a PR diff as a "review", but doesn't treat the
334
+ # content in the review comment as a comment. Thus, we search through comments to
335
+ # see if there's any new comments in the review (i.e. that aren't in-reply-to
336
+ # anything) and ignore any reviews which do not have any fresh comments and do not
337
+ # have a review "body" (which is always empty for comment "reviews").
320
338
self .logger .info (f"Concluded that reivew id { review_id } is not a real review. It is theoretically at { review_web_url } " )
321
339
return
322
340
0 commit comments