Skip to content

Commit 0331578

Browse files
committed
fix copilot user unhanded in scm client
1 parent 708d3fe commit 0331578

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

patchwork/common/client/scm.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import gitlab.const
1111
from attrs import define
1212
from github import Auth, Consts, Github, GithubException, PullRequest
13+
from github.GithubException import UnknownObjectException
1314
from gitlab import Gitlab, GitlabAuthenticationError, GitlabError
1415
from gitlab.v4.objects import ProjectMergeRequest
1516
from giturlparse import GitUrlParsed, parse
@@ -333,13 +334,20 @@ def reset_comments(self) -> None:
333334
comment.delete()
334335

335336
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+
336347
return dict(
337348
title=self._pr.title or "",
338349
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,
343351
# None checks for binary files
344352
diffs={file.filename: file.patch for file in self._pr.get_files() if file.patch is not None},
345353
)

0 commit comments

Comments
 (0)