mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
Only sync tags after all batches (#9319)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
parent
c3d31e5534
commit
3bf5a07537
@ -11,7 +11,7 @@ type Uploader interface {
|
|||||||
CreateRepo(repo *Repository, opts MigrateOptions) error
|
CreateRepo(repo *Repository, opts MigrateOptions) error
|
||||||
CreateTopics(topic ...string) error
|
CreateTopics(topic ...string) error
|
||||||
CreateMilestones(milestones ...*Milestone) error
|
CreateMilestones(milestones ...*Milestone) error
|
||||||
CreateReleases(releases ...*Release) error
|
CreateReleases(syncTags bool, releases ...*Release) error
|
||||||
CreateLabels(labels ...*Label) error
|
CreateLabels(labels ...*Label) error
|
||||||
CreateIssues(issues ...*Issue) error
|
CreateIssues(issues ...*Issue) error
|
||||||
CreateComments(comments ...*Comment) error
|
CreateComments(comments ...*Comment) error
|
||||||
|
@ -201,7 +201,7 @@ func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateReleases creates releases
|
// CreateReleases creates releases
|
||||||
func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
|
func (g *GiteaLocalUploader) CreateReleases(syncTags bool, releases ...*base.Release) error {
|
||||||
var rels = make([]*models.Release, 0, len(releases))
|
var rels = make([]*models.Release, 0, len(releases))
|
||||||
for _, release := range releases {
|
for _, release := range releases {
|
||||||
var rel = models.Release{
|
var rel = models.Release{
|
||||||
@ -292,8 +292,12 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if syncTags {
|
||||||
// sync tags to releases in database
|
// sync tags to releases in database
|
||||||
return models.SyncReleasesWithTags(g.repo, g.gitRepo)
|
return models.SyncReleasesWithTags(g.repo, g.gitRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateIssues creates issues
|
// CreateIssues creates issues
|
||||||
|
@ -161,12 +161,16 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts
|
|||||||
}
|
}
|
||||||
|
|
||||||
relBatchSize := uploader.MaxBatchInsertSize("release")
|
relBatchSize := uploader.MaxBatchInsertSize("release")
|
||||||
|
syncTags := false
|
||||||
for len(releases) > 0 {
|
for len(releases) > 0 {
|
||||||
|
if len(releases) <= relBatchSize {
|
||||||
if len(releases) < relBatchSize {
|
if len(releases) < relBatchSize {
|
||||||
relBatchSize = len(releases)
|
relBatchSize = len(releases)
|
||||||
}
|
}
|
||||||
|
syncTags = true
|
||||||
|
}
|
||||||
|
|
||||||
if err := uploader.CreateReleases(releases[:relBatchSize]...); err != nil {
|
if err := uploader.CreateReleases(syncTags, releases[:relBatchSize]...); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
releases = releases[relBatchSize:]
|
releases = releases[relBatchSize:]
|
||||||
|
Loading…
Reference in New Issue
Block a user