Skip to content

Commit ecd33f4

Browse files
committed
Fix out of range error from totalCount
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
1 parent 3436ce9 commit ecd33f4

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

reviewrot/githubstack.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,19 @@ def get_last_comment(self, pr):
193193
last_issue_comment = None
194194
last_comment = None
195195

196-
if review_comments.totalCount > 0:
196+
try:
197+
# review_comments.totalCount may return a non-zero value when
198+
# the list of comments is actually empty :(
197199
last_review_comment = review_comments.reversed[0]
200+
except IndexError:
201+
pass
198202

199-
if issue_comments.totalCount > 0:
203+
try:
204+
# issue_comments.totalCount may return a non-zero value when
205+
# the list of comments is actually empty :(
200206
last_issue_comment = issue_comments.reversed[0]
207+
except IndexError:
208+
pass
201209

202210
# check which is newer if pr has both types of comments
203211
if last_issue_comment and last_review_comment:

0 commit comments

Comments
 (0)