mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
Prevent NPE whilst migrating if there is a team request review (#19855)
A pr.Reviewer may be nil when migrating from Gitea if this is a team request review. We do not migrate teams therefore we cannot map these requests, but we can migrate user requests. Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
@@ -639,6 +639,11 @@ func (g *GiteaDownloader) GetReviews(reviewable base.Reviewable) ([]*base.Review
|
||||
}
|
||||
|
||||
for _, pr := range prl {
|
||||
if pr.Reviewer == nil {
|
||||
// Presumably this is a team review which we cannot migrate at present but we have to skip this review as otherwise the review will be mapped on to an incorrect user.
|
||||
// TODO: handle team reviews
|
||||
continue
|
||||
}
|
||||
|
||||
rcl, _, err := g.client.ListPullReviewComments(g.repoOwner, g.repoName, reviewable.GetForeignIndex(), pr.ID)
|
||||
if err != nil {
|
||||
@@ -664,7 +669,7 @@ func (g *GiteaDownloader) GetReviews(reviewable base.Reviewable) ([]*base.Review
|
||||
})
|
||||
}
|
||||
|
||||
allReviews = append(allReviews, &base.Review{
|
||||
review := &base.Review{
|
||||
ID: pr.ID,
|
||||
IssueIndex: reviewable.GetLocalIndex(),
|
||||
ReviewerID: pr.Reviewer.ID,
|
||||
@@ -675,7 +680,9 @@ func (g *GiteaDownloader) GetReviews(reviewable base.Reviewable) ([]*base.Review
|
||||
CreatedAt: pr.Submitted,
|
||||
State: string(pr.State),
|
||||
Comments: reviewComments,
|
||||
})
|
||||
}
|
||||
|
||||
allReviews = append(allReviews, review)
|
||||
}
|
||||
|
||||
if len(prl) < g.maxPerPage {
|
||||
|
Reference in New Issue
Block a user