Skip to content

Commit ebb64ff

Browse files
committed
added get_comments
1 parent 9fbd07e commit ebb64ff

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

ForgejoRepoAPI.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def get_forks(self, repo: Repository) -> list[Repository]:
190190

191191
for fork in forks:
192192
default_branch = Branch(name=fork.default_branch,last_commit=None)
193-
owner = fork.owner
193+
owner = fork.owner
194194

195195
result.append(
196196
Repository(
@@ -208,8 +208,36 @@ def get_forks(self, repo: Repository) -> list[Repository]:
208208
logging.error(f"Failed to get forks from Forgejo for repo {repo.name}: {e}")
209209
return []
210210

211-
def get_comments(self, obj) -> list[Comment]:
212-
return []
211+
def get_comments(self, repo, obj) -> list[Comment]:
212+
result = []
213+
try:
214+
if isinstance(obj, Issue):
215+
comments = self.client.issue.get_repo_comments(repo.owner.login, repo.name)
216+
result = [
217+
Comment(
218+
body=c.body,
219+
created_at=c.created_at,
220+
author=self.get_user_data(c.user),
221+
)
222+
for c in comments
223+
]
224+
225+
elif isinstance(obj, PullRequest):
226+
comments = self.client.repository.repo_get_pull_review_comments(repo.owner.login, repo.name, obj._id,
227+
100000) # нет id комментария
228+
result = [
229+
Comment(
230+
body=c.body,
231+
created_at=c.created_at,
232+
author=self.get_user_data(c.user),
233+
)
234+
for c in comments
235+
]
236+
237+
except Exception as e:
238+
logging.error(f"Failed to get comments for repo {repo.name}: {e}")
239+
240+
return result
213241

214242
def get_invites(self, repo: Repository) -> list[Invite]:
215243
return []

0 commit comments

Comments
 (0)