@@ -32,11 +32,21 @@ def _get_last_author_activity(
3232 return None
3333 last_activity = None
3434 for commit in pr .get_commits ():
35- commit_date = commit .commit .author .date
36- if commit_date > after_date :
37- if commit .author and commit .author .login == pr_author :
38- if not last_activity or commit_date > last_activity :
39- last_activity = commit_date
35+ author_date = commit .commit .author .date if commit .commit .author else None
36+ committer_date = (
37+ commit .commit .committer .date if commit .commit .committer else None
38+ )
39+ if author_date and committer_date :
40+ commit_date = max (author_date , committer_date )
41+ else :
42+ commit_date = author_date or committer_date
43+ if not commit_date or commit_date <= after_date :
44+ continue
45+ author_login = commit .author .login if commit .author else None
46+ committer_login = commit .committer .login if commit .committer else None
47+ if author_login == pr_author or committer_login == pr_author :
48+ if not last_activity or commit_date > last_activity :
49+ last_activity = commit_date
4050 if issue_comments is None :
4151 issue_comments = list (pr .get_issue_comments ())
4252 for comment in issue_comments :
@@ -160,13 +170,25 @@ def get_last_changes_requested(self, pr, all_reviews=None):
160170 try :
161171 if all_reviews is None :
162172 all_reviews = list (pr .get_reviews ())
163- changes_requested_reviews = [
164- r for r in all_reviews if r .state == "CHANGES_REQUESTED"
173+ latest_per_reviewer = {}
174+ for r in all_reviews :
175+ if not r .user or not r .submitted_at :
176+ continue
177+ if r .user .type == "Bot" :
178+ continue
179+ if r .state == "COMMENTED" :
180+ continue
181+ current = latest_per_reviewer .get (r .user .login )
182+ if current is None or r .submitted_at > current .submitted_at :
183+ latest_per_reviewer [r .user .login ] = r
184+ blocking = [
185+ r
186+ for r in latest_per_reviewer .values ()
187+ if r .state == "CHANGES_REQUESTED"
165188 ]
166- if not changes_requested_reviews :
189+ if not blocking :
167190 return None
168- changes_requested_reviews .sort (key = lambda r : r .submitted_at , reverse = True )
169- return changes_requested_reviews [0 ].submitted_at
191+ return max (blocking , key = lambda r : r .submitted_at ).submitted_at
170192 except Exception as e :
171193 print ("Error getting reviews" f" for PR #{ pr .number } : { e } " )
172194 return None
0 commit comments