Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent NPE whilst migrating if there is a team request review #19855

Merged
1 change: 1 addition & 0 deletions modules/migration/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
ReviewStateApproved = "APPROVED"
ReviewStateChangesRequested = "CHANGES_REQUESTED"
ReviewStateCommented = "COMMENTED"
ReviewStateRequestReview = "REQUEST_REVIEW"
zeripath marked this conversation as resolved.
Show resolved Hide resolved
)

// Review is a standard review information
Expand Down
32 changes: 20 additions & 12 deletions services/migrations/gitea_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,18 +664,26 @@ func (g *GiteaDownloader) GetReviews(reviewable base.Reviewable) ([]*base.Review
})
}

allReviews = append(allReviews, &base.Review{
ID: pr.ID,
IssueIndex: reviewable.GetLocalIndex(),
ReviewerID: pr.Reviewer.ID,
ReviewerName: pr.Reviewer.UserName,
Official: pr.Official,
CommitID: pr.CommitID,
Content: pr.Body,
CreatedAt: pr.Submitted,
State: string(pr.State),
Comments: reviewComments,
})
review := &base.Review{
ID: pr.ID,
IssueIndex: reviewable.GetLocalIndex(),
Official: pr.Official,
CommitID: pr.CommitID,
Content: pr.Body,
CreatedAt: pr.Submitted,
State: string(pr.State),
Comments: reviewComments,
}

if pr.Reviewer != nil {
review.ReviewerID = pr.Reviewer.ID
review.ReviewerName = pr.Reviewer.UserName
} else {
// we have to skip this review as it will be mapped on to something incorrect
zeripath marked this conversation as resolved.
Show resolved Hide resolved
continue
}

allReviews = append(allReviews, review)
zeripath marked this conversation as resolved.
Show resolved Hide resolved
}

if len(prl) < g.maxPerPage {
Expand Down
2 changes: 2 additions & 0 deletions services/migrations/gitea_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@ func convertReviewState(state string) models.ReviewType {
return models.ReviewTypeReject
case base.ReviewStateCommented:
return models.ReviewTypeComment
case base.ReviewStateRequestReview:
return models.ReviewTypeRequest
default:
return models.ReviewTypePending
}
Expand Down