diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-08-25 04:31:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 04:31:57 +0200 |
commit | 1d8543e7db58d7c4973758e47f005c4d8bd7d7a3 (patch) | |
tree | b60c99e2dfd69ccb998f8a0829d98d7cadcf0d6b /services/migrations | |
parent | [skip ci] Updated translations via Crowdin (diff) | |
download | forgejo-1d8543e7db58d7c4973758e47f005c4d8bd7d7a3.tar.xz forgejo-1d8543e7db58d7c4973758e47f005c4d8bd7d7a3.zip |
Move some files into models' sub packages (#20262)
* Move some files into models' sub packages
* Move functions
* merge main branch
* Fix check
* fix check
* Fix some tests
* Fix lint
* Fix lint
* Revert lint changes
* Fix error comments
* Fix lint
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'services/migrations')
-rw-r--r-- | services/migrations/gitea_uploader.go | 8 | ||||
-rw-r--r-- | services/migrations/gitea_uploader_test.go | 15 |
2 files changed, 11 insertions, 12 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index c7a6f9b02f..79b22bef78 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -83,7 +83,7 @@ func (g *GiteaLocalUploader) MaxBatchInsertSize(tp string) int { case "label": return db.MaxBatchInsertSize(new(issues_model.Label)) case "release": - return db.MaxBatchInsertSize(new(models.Release)) + return db.MaxBatchInsertSize(new(repo_model.Release)) case "pullrequest": return db.MaxBatchInsertSize(new(issues_model.PullRequest)) } @@ -99,7 +99,7 @@ func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.Migrate var r *repo_model.Repository if opts.MigrateToRepoID <= 0 { - r, err = repo_module.CreateRepository(g.doer, owner, models.CreateRepoOptions{ + r, err = repo_module.CreateRepository(g.doer, owner, repo_module.CreateRepoOptions{ Name: g.repoName, Description: repo.Description, OriginalURL: repo.OriginalURL, @@ -237,7 +237,7 @@ func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error { // CreateReleases creates releases func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { - rels := make([]*models.Release, 0, len(releases)) + rels := make([]*repo_model.Release, 0, len(releases)) for _, release := range releases { if release.Created.IsZero() { if !release.Published.IsZero() { @@ -247,7 +247,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { } } - rel := models.Release{ + rel := repo_model.Release{ RepoID: g.repo.ID, TagName: release.TagName, LowerTagName: strings.ToLower(release.TagName), diff --git a/services/migrations/gitea_uploader_test.go b/services/migrations/gitea_uploader_test.go index 1f1c4bde6f..715dbf7a5c 100644 --- a/services/migrations/gitea_uploader_test.go +++ b/services/migrations/gitea_uploader_test.go @@ -15,7 +15,6 @@ import ( "testing" "time" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" issues_model "code.gitea.io/gitea/models/issues" repo_model "code.gitea.io/gitea/models/repo" @@ -85,7 +84,7 @@ func TestGiteaUploadRepo(t *testing.T) { assert.NoError(t, err) assert.Len(t, labels, 12) - releases, err := models.GetReleasesByRepoID(repo.ID, models.FindReleasesOptions{ + releases, err := repo_model.GetReleasesByRepoID(repo.ID, repo_model.FindReleasesOptions{ ListOptions: db.ListOptions{ PageSize: 10, Page: 0, @@ -95,7 +94,7 @@ func TestGiteaUploadRepo(t *testing.T) { assert.NoError(t, err) assert.Len(t, releases, 8) - releases, err = models.GetReleasesByRepoID(repo.ID, models.FindReleasesOptions{ + releases, err = repo_model.GetReleasesByRepoID(repo.ID, repo_model.FindReleasesOptions{ ListOptions: db.ListOptions{ PageSize: 10, Page: 0, @@ -146,7 +145,7 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) { // The externalID does not match any existing user, everything // belongs to the doer // - target := models.Release{} + target := repo_model.Release{} uploader.userMap = make(map[int64]int64) err := uploader.remapUser(&source, &target) assert.NoError(t, err) @@ -157,7 +156,7 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) { // everything belongs to the doer // source.PublisherID = user.ID - target = models.Release{} + target = repo_model.Release{} uploader.userMap = make(map[int64]int64) err = uploader.remapUser(&source, &target) assert.NoError(t, err) @@ -168,7 +167,7 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) { // belongs to the existing user // source.PublisherName = user.Name - target = models.Release{} + target = repo_model.Release{} uploader.userMap = make(map[int64]int64) err = uploader.remapUser(&source, &target) assert.NoError(t, err) @@ -197,7 +196,7 @@ func TestGiteaUploadRemapExternalUser(t *testing.T) { // by the doer // uploader.userMap = make(map[int64]int64) - target := models.Release{} + target := repo_model.Release{} err := uploader.remapUser(&source, &target) assert.NoError(t, err) assert.EqualValues(t, doer.ID, target.GetUserID()) @@ -220,7 +219,7 @@ func TestGiteaUploadRemapExternalUser(t *testing.T) { // the migrated data // uploader.userMap = make(map[int64]int64) - target = models.Release{} + target = repo_model.Release{} err = uploader.remapUser(&source, &target) assert.NoError(t, err) assert.EqualValues(t, linkedUser.ID, target.GetUserID()) |