Skip to content

Fix migration releases (#9319) (#9326) #9328

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/migrations/base/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Uploader interface {
CreateTopics(topic ...string) error
CreateMilestones(milestones ...*Milestone) error
CreateReleases(releases ...*Release) error
SyncTags() error
CreateLabels(labels ...*Label) error
CreateIssues(issues ...*Issue) error
CreateComments(comments ...*Comment) error
Expand Down
9 changes: 5 additions & 4 deletions modules/migrations/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,12 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {

rels = append(rels, &rel)
}
if err := models.InsertReleases(rels...); err != nil {
return err
}

// sync tags to releases in database
return models.InsertReleases(rels...)
}

// SyncTags syncs releases with tags in the database
func (g *GiteaLocalUploader) SyncTags() error {
return models.SyncReleasesWithTags(g.repo, g.gitRepo)
}

Expand Down
5 changes: 5 additions & 0 deletions modules/migrations/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts
}
releases = releases[relBatchSize:]
}

// Once all releases (if any) are inserted, sync any remaining non-release tags
if err := uploader.SyncTags(); err != nil {
return err
}
}

var commentBatchSize = uploader.MaxBatchInsertSize("comment")
Expand Down