|
10 | 10 | import gitlab.const |
11 | 11 | from attrs import define |
12 | 12 | from github import Auth, Consts, Github, GithubException, PullRequest |
| 13 | +from github.GithubException import UnknownObjectException |
13 | 14 | from gitlab import Gitlab, GitlabAuthenticationError, GitlabError |
14 | 15 | from gitlab.v4.objects import ProjectMergeRequest |
15 | 16 | from giturlparse import GitUrlParsed, parse |
@@ -333,13 +334,20 @@ def reset_comments(self) -> None: |
333 | 334 | comment.delete() |
334 | 335 |
|
335 | 336 | def texts(self) -> PullRequestTexts: |
| 337 | + comments = [] |
| 338 | + for comment in chain(self._pr.get_review_comments(), self._pr.get_issue_comments()): |
| 339 | + try: |
| 340 | + # Copilot user throws here |
| 341 | + user = comment.user.name |
| 342 | + except UnknownObjectException: |
| 343 | + user = comment.user.login |
| 344 | + |
| 345 | + comments.append(dict(user=user, body=comment.body)) |
| 346 | + |
336 | 347 | return dict( |
337 | 348 | title=self._pr.title or "", |
338 | 349 | body=self._pr.body or "", |
339 | | - comments=[ |
340 | | - dict(user=comment.user.name, body=comment.body) |
341 | | - for comment in itertools.chain(self._pr.get_comments(), self._pr.get_issue_comments()) |
342 | | - ], |
| 350 | + comments=comments, |
343 | 351 | # None checks for binary files |
344 | 352 | diffs={file.filename: file.patch for file in self._pr.get_files() if file.patch is not None}, |
345 | 353 | ) |
|
0 commit comments