mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-23 08:26:35 +08:00
migrations: remove dead code in gitea uploader (#18725)
When migrating, g.issues is a map with all issues created during the migration. If an issue is not found in g.issues when inserting a comment or a review, it cannot exist in the database and trying to get it via GetIssueByIndex() will always fail and return an error. Signed-off-by: singuliere <singuliere@autistici.org>
This commit is contained in:
parent
15a4b1d42b
commit
54dd0fc88b
|
@ -416,12 +416,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
|
||||||
var issue *models.Issue
|
var issue *models.Issue
|
||||||
issue, ok := g.issues[comment.IssueIndex]
|
issue, ok := g.issues[comment.IssueIndex]
|
||||||
if !ok {
|
if !ok {
|
||||||
var err error
|
return fmt.Errorf("comment references non existent IssueIndex %d", comment.IssueIndex)
|
||||||
issue, err = models.GetIssueByIndex(g.repo.ID, comment.IssueIndex)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
g.issues[comment.IssueIndex] = issue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if comment.Created.IsZero() {
|
if comment.Created.IsZero() {
|
||||||
|
@ -685,19 +680,14 @@ func convertReviewState(state string) models.ReviewType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateReviews create pull request reviews
|
// CreateReviews create pull request reviews of currently migrated issues
|
||||||
func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
|
func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
|
||||||
cms := make([]*models.Review, 0, len(reviews))
|
cms := make([]*models.Review, 0, len(reviews))
|
||||||
for _, review := range reviews {
|
for _, review := range reviews {
|
||||||
var issue *models.Issue
|
var issue *models.Issue
|
||||||
issue, ok := g.issues[review.IssueIndex]
|
issue, ok := g.issues[review.IssueIndex]
|
||||||
if !ok {
|
if !ok {
|
||||||
var err error
|
return fmt.Errorf("review references non existent IssueIndex %d", review.IssueIndex)
|
||||||
issue, err = models.GetIssueByIndex(g.repo.ID, review.IssueIndex)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
g.issues[review.IssueIndex] = issue
|
|
||||||
}
|
}
|
||||||
if review.CreatedAt.IsZero() {
|
if review.CreatedAt.IsZero() {
|
||||||
review.CreatedAt = time.Unix(int64(issue.CreatedUnix), 0)
|
review.CreatedAt = time.Unix(int64(issue.CreatedUnix), 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user