diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-07-02 05:17:16 +0800 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-07-01 22:17:16 +0100 |
commit | e728b5581291d6d9a62fcd8ab2c3b2e6c89b7138 (patch) | |
tree | 5ea593bc5394e271254746464fd1da8338dc3499 /modules/migrations/gitea.go | |
parent | 9fdd199cca780a13b44a667ee862b1ec3ff37958 (diff) | |
download | gitea-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/migrations/gitea.go')
-rw-r--r-- | modules/migrations/gitea.go | 22 |
1 files changed, 14 insertions, 8 deletions
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 |