Skip to content

Commit 3f1f798

Browse files
committed
Fix bug when an issue not have any comments, and get comments
1 parent 261be02 commit 3f1f798

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

script.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
g = Github(ACCESS_TOKEN)
3232

3333
# Get the repository object
34+
print(repository_owner)
35+
print(repository_name)
3436
repo = g.get_repo(f"{repository_owner}/{repository_name}")
3537

3638
# Get all the issues in the repository with the "auto-release" label
@@ -45,8 +47,17 @@
4547
print(f"Issue: {issue.title}")
4648
print("body: <<<", issue.body, ">>>")
4749

50+
print(issue)
4851
comments = list(issue.get_comments()).reverse()
49-
for comment in comments:
50-
print(f"\tComment: {comment.body}")
52+
comments = issue.get_comments()
53+
print(comments.totalCount)
54+
if comments.totalCount > 0:
55+
# reverse iterate over comments
56+
for i in range(comments.totalCount - 1, -1, -1):
57+
print("------------------------")
58+
print(comments[i].body)
59+
print("------------------------")
60+
else:
61+
print("No comments in this issue")
5162

5263
print("\n\n")

0 commit comments

Comments
 (0)