diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-01-10 23:35:17 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-10 23:35:17 +0800 |
commit | 7a3a90aca3c4a8258805efa10022a81e4d1a4d73 (patch) | |
tree | 54d92bac08a2aa336825cd1545dcd19fba028c96 /routers/repo/repo.go | |
parent | 3143bb10da25cd66383c23aff7b31dbd7c3dd9d6 (diff) | |
download | gitea-7a3a90aca3c4a8258805efa10022a81e4d1a4d73.tar.gz gitea-7a3a90aca3c4a8258805efa10022a81e4d1a4d73.zip |
Fix wrong original git service type on a migrated repository (#9693)
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r-- | routers/repo/repo.go | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go index d6d91f0843..0bd9f1d56b 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -6,6 +6,7 @@ package repo import ( "fmt" + "net/url" "os" "path" "strings" @@ -18,6 +19,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/migrations" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/task" "code.gitea.io/gitea/modules/util" repo_service "code.gitea.io/gitea/services/repository" @@ -330,22 +332,29 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { return } + var gitServiceType = structs.PlainGitService + u, err := url.Parse(form.CloneAddr) + if err == nil && strings.EqualFold(u.Host, "github.com") { + gitServiceType = structs.GithubService + } + var opts = migrations.MigrateOptions{ - OriginalURL: form.CloneAddr, - CloneAddr: remoteAddr, - RepoName: form.RepoName, - Description: form.Description, - Private: form.Private || setting.Repository.ForcePrivate, - Mirror: form.Mirror, - AuthUsername: form.AuthUsername, - AuthPassword: form.AuthPassword, - Wiki: form.Wiki, - Issues: form.Issues, - Milestones: form.Milestones, - Labels: form.Labels, - Comments: true, - PullRequests: form.PullRequests, - Releases: form.Releases, + OriginalURL: form.CloneAddr, + GitServiceType: gitServiceType, + CloneAddr: remoteAddr, + RepoName: form.RepoName, + Description: form.Description, + Private: form.Private || setting.Repository.ForcePrivate, + Mirror: form.Mirror, + AuthUsername: form.AuthUsername, + AuthPassword: form.AuthPassword, + Wiki: form.Wiki, + Issues: form.Issues, + Milestones: form.Milestones, + Labels: form.Labels, + Comments: true, + PullRequests: form.PullRequests, + Releases: form.Releases, } if opts.Mirror { opts.Issues = false |