Skip to content

Commit

Permalink
Fix migration releases (#9319) (#9326) (#9328)
Browse files Browse the repository at this point in the history
* Only sync tags after all batches (#9319)

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add SyncTags to uploader interface (#9326)

* Add sync tags to interface

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix revive

Signed-off-by: jolheiser <john.olheiser@gmail.com>
  • Loading branch information
jolheiser authored and techknowlogick committed Dec 12, 2019
1 parent f11df80 commit 9ef148a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
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

0 comments on commit 9ef148a

Please sign in to comment.