diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-09-09 05:09:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 21:09:23 +0000 |
commit | e3ed67859a434f2fef1db175e9c82251a7f9f6c9 (patch) | |
tree | e4c48b0c17d6d5a9507c3fc1479d7da2faba59dd /services/migrations | |
parent | b8ad558c93052ee3e2f43f1e24e6f5c134da36c4 (diff) | |
download | gitea-e3ed67859a434f2fef1db175e9c82251a7f9f6c9.tar.gz gitea-e3ed67859a434f2fef1db175e9c82251a7f9f6c9.zip |
Move some functions to service layer (#26969)
Diffstat (limited to 'services/migrations')
-rw-r--r-- | services/migrations/gitea_uploader.go | 10 | ||||
-rw-r--r-- | services/migrations/update.go | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go index 3f055707ae..4c21efae44 100644 --- a/services/migrations/gitea_uploader.go +++ b/services/migrations/gitea_uploader.go @@ -205,7 +205,7 @@ func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) err mss = append(mss, &ms) } - err := models.InsertMilestones(mss...) + err := issues_model.InsertMilestones(mss...) if err != nil { return err } @@ -350,7 +350,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { rels = append(rels, &rel) } - return models.InsertReleases(rels...) + return repo_model.InsertReleases(rels...) } // SyncTags syncs releases with tags in the database @@ -430,7 +430,7 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error { } if len(iss) > 0 { - if err := models.InsertIssues(iss...); err != nil { + if err := issues_model.InsertIssues(iss...); err != nil { return err } @@ -510,7 +510,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error { if len(cms) == 0 { return nil } - return models.InsertIssueComments(cms) + return issues_model.InsertIssueComments(cms) } // CreatePullRequests creates pull requests @@ -529,7 +529,7 @@ func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error gprs = append(gprs, gpr) } - if err := models.InsertPullRequests(ctx, gprs...); err != nil { + if err := issues_model.InsertPullRequests(ctx, gprs...); err != nil { return err } for _, pr := range gprs { diff --git a/services/migrations/update.go b/services/migrations/update.go index 48b61885e8..2adca01dfe 100644 --- a/services/migrations/update.go +++ b/services/migrations/update.go @@ -6,11 +6,11 @@ package migrations import ( "context" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/services/externalaccount" ) // UpdateMigrationPosterID updates all migrated repositories' issues and comments posterID @@ -62,7 +62,7 @@ func updateMigrationPosterIDByGitService(ctx context.Context, tp structs.GitServ default: } externalUserID := user.ExternalID - if err := models.UpdateMigrationsByType(tp, externalUserID, user.UserID); err != nil { + if err := externalaccount.UpdateMigrationsByType(tp, externalUserID, user.UserID); err != nil { log.Error("UpdateMigrationsByType type %s external user id %v to local user id %v failed: %v", tp.Name(), user.ExternalID, user.UserID, err) } } |