diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/migrations/migrations.go | 2 | ||||
-rw-r--r-- | models/migrations/v119.go | 16 | ||||
-rw-r--r-- | models/repo.go | 24 | ||||
-rw-r--r-- | models/task.go | 13 |
4 files changed, 38 insertions, 17 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index f26566b045..dc5cc48c64 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -292,6 +292,8 @@ var migrations = []Migration{ NewMigration("Add block on rejected reviews branch protection", addBlockOnRejectedReviews), // v118 -> v119 NewMigration("Add commit id and stale to reviews", addReviewCommitAndStale), + // v119 -> v120 + NewMigration("Fix migrated repositories' git service type", fixMigratedRepositoryServiceType), } // Migrate database to current version diff --git a/models/migrations/v119.go b/models/migrations/v119.go new file mode 100644 index 0000000000..746a04ead4 --- /dev/null +++ b/models/migrations/v119.go @@ -0,0 +1,16 @@ +// Copyright 2020 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package migrations + +import ( + "code.gitea.io/gitea/modules/structs" + + "xorm.io/xorm" +) + +func fixMigratedRepositoryServiceType(x *xorm.Engine) error { + _, err := x.Exec("UPDATE repository SET original_service_type = ? WHERE original_url LIKE 'https://github.com/%'", structs.GithubService) + return err +} diff --git a/models/repo.go b/models/repo.go index 0dbdcc11b5..6c9623ea2c 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1071,17 +1071,18 @@ func initRepoCommit(tmpPath string, repo *Repository, u *User) (err error) { // CreateRepoOptions contains the create repository options type CreateRepoOptions struct { - Name string - Description string - OriginalURL string - Gitignores string - IssueLabels string - License string - Readme string - IsPrivate bool - IsMirror bool - AutoInit bool - Status RepositoryStatus + Name string + Description string + OriginalURL string + GitServiceType structs.GitServiceType + Gitignores string + IssueLabels string + License string + Readme string + IsPrivate bool + IsMirror bool + AutoInit bool + Status RepositoryStatus } func getRepoInitFile(tp, name string) ([]byte, error) { @@ -1369,6 +1370,7 @@ func CreateRepository(doer, u *User, opts CreateRepoOptions) (_ *Repository, err LowerName: strings.ToLower(opts.Name), Description: opts.Description, OriginalURL: opts.OriginalURL, + OriginalServiceType: opts.GitServiceType, IsPrivate: opts.IsPrivate, IsFsckEnabled: !opts.IsMirror, CloseIssuesViaCommitInAnyBranch: setting.Repository.DefaultCloseIssuesViaCommitsInAnyBranch, diff --git a/models/task.go b/models/task.go index 763644e039..e1d751bc3c 100644 --- a/models/task.go +++ b/models/task.go @@ -194,12 +194,13 @@ func CreateMigrateTask(doer, u *User, opts base.MigrateOptions) (*Task, error) { } repo, err := CreateRepository(doer, u, CreateRepoOptions{ - Name: opts.RepoName, - Description: opts.Description, - OriginalURL: opts.OriginalURL, - IsPrivate: opts.Private, - IsMirror: opts.Mirror, - Status: RepositoryBeingMigrated, + Name: opts.RepoName, + Description: opts.Description, + OriginalURL: opts.OriginalURL, + GitServiceType: opts.GitServiceType, + IsPrivate: opts.Private, + IsMirror: opts.Mirror, + Status: RepositoryBeingMigrated, }) if err != nil { task.EndTime = timeutil.TimeStampNow() |