diff --git a/modules/migrations/base/uploader.go b/modules/migrations/base/uploader.go index ae1be84b8..257c7a290 100644 --- a/modules/migrations/base/uploader.go +++ b/modules/migrations/base/uploader.go @@ -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 diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go index 81a6116a2..18f4da758 100644 --- a/modules/migrations/gitea.go +++ b/modules/migrations/gitea.go @@ -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) } diff --git a/modules/migrations/migrate.go b/modules/migrations/migrate.go index 7a5071e12..e2a2c8b7e 100644 --- a/modules/migrations/migrate.go +++ b/modules/migrations/migrate.go @@ -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")