summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-07-02 05:17:16 +0800
committerzeripath <art27@cantab.net>2019-07-01 22:17:16 +0100
commite728b5581291d6d9a62fcd8ab2c3b2e6c89b7138 (patch)
tree5ea593bc5394e271254746464fd1da8338dc3499 /modules
parent9fdd199cca780a13b44a667ee862b1ec3ff37958 (diff)
downloadgitea-e728b5581291d6d9a62fcd8ab2c3b2e6c89b7138.tar.gz
gitea-e728b5581291d6d9a62fcd8ab2c3b2e6c89b7138.zip
Fix bug conflict between SyncReleasesWithTags and InsertReleases (#7337)
* fix bug conflict between SyncReleasesWithTags and InsertReleases * fix tests * fix fmt
Diffstat (limited to 'modules')
-rw-r--r--modules/migrations/base/uploader.go2
-rw-r--r--modules/migrations/gitea.go22
-rw-r--r--modules/migrations/migrate.go2
3 files changed, 16 insertions, 10 deletions
diff --git a/modules/migrations/base/uploader.go b/modules/migrations/base/uploader.go
index 096a8ab8f0..9d2fd2af6a 100644
--- a/modules/migrations/base/uploader.go
+++ b/modules/migrations/base/uploader.go
@@ -7,7 +7,7 @@ package base
// Uploader uploads all the informations of one repository
type Uploader interface {
- CreateRepo(repo *Repository, includeWiki bool) error
+ CreateRepo(repo *Repository, opts MigrateOptions) error
CreateMilestones(milestones ...*Milestone) error
CreateReleases(releases ...*Release) error
CreateLabels(labels ...*Label) error
diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go
index 7d5a50d307..bfc5e49033 100644
--- a/modules/migrations/gitea.go
+++ b/modules/migrations/gitea.go
@@ -54,19 +54,20 @@ func NewGiteaLocalUploader(doer *models.User, repoOwner, repoName string) *Gitea
}
// CreateRepo creates a repository
-func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, includeWiki bool) error {
+func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.MigrateOptions) error {
owner, err := models.GetUserByName(g.repoOwner)
if err != nil {
return err
}
r, err := models.MigrateRepository(g.doer, owner, models.MigrateRepoOptions{
- Name: g.repoName,
- Description: repo.Description,
- IsMirror: repo.IsMirror,
- RemoteAddr: repo.CloneURL,
- IsPrivate: repo.IsPrivate,
- Wiki: includeWiki,
+ Name: g.repoName,
+ Description: repo.Description,
+ IsMirror: repo.IsMirror,
+ RemoteAddr: repo.CloneURL,
+ IsPrivate: repo.IsPrivate,
+ Wiki: opts.Wiki,
+ SyncReleasesWithTags: !opts.Releases, // if didn't get releases, then sync them from tags
})
g.repo = r
if err != nil {
@@ -198,7 +199,12 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
rels = append(rels, &rel)
}
- return models.InsertReleases(rels...)
+ if err := models.InsertReleases(rels...); err != nil {
+ return err
+ }
+
+ // sync tags to releases in database
+ return models.SyncReleasesWithTags(g.repo, g.gitRepo)
}
// CreateIssues creates issues
diff --git a/modules/migrations/migrate.go b/modules/migrations/migrate.go
index 3a4e6b2dbe..ce8f9b8022 100644
--- a/modules/migrations/migrate.go
+++ b/modules/migrations/migrate.go
@@ -80,7 +80,7 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts
repo.Description = opts.Description
}
log.Trace("migrating git data")
- if err := uploader.CreateRepo(repo, opts.Wiki); err != nil {
+ if err := uploader.CreateRepo(repo, opts); err != nil {
return err
}