diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-06-11 21:50:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-11 21:50:14 +0800 |
commit | ce3dd04c63a048fe791ed864c2023fd37b09e427 (patch) | |
tree | 43ed415dc8d5647b59bf54fddceb4d4a63bcc456 /routers/web/repo | |
parent | 88f2e457d891c4e91a9eddab8143d0109e08dfa9 (diff) | |
download | gitea-ce3dd04c63a048fe791ed864c2023fd37b09e427.tar.gz gitea-ce3dd04c63a048fe791ed864c2023fd37b09e427.zip |
Fix some mirror bugs (#18649)
* Fix some mirror bugs
* Remove unnecessary code
* Fix lint
* rename stdard url
* Allow more charactors in git ssh protocol url
* improve the detection
* support ipv6 for git url parse
* Fix bug
* Fix template
* Fix bug
* fix template
* Fix tmpl
* Fix tmpl
* Fix parse ssh with interface
* Rename functions name
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers/web/repo')
-rw-r--r-- | routers/web/repo/setting.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index f49ef6e85d..6083d17fa5 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -215,22 +215,24 @@ func SettingsPost(ctx *context.Context) { return } - u, _ := git.GetRemoteAddress(ctx, ctx.Repo.Repository.RepoPath(), ctx.Repo.Mirror.GetRemoteName()) + u, err := git.GetRemoteURL(ctx, ctx.Repo.Repository.RepoPath(), ctx.Repo.Mirror.GetRemoteName()) + if err != nil { + ctx.Data["Err_MirrorAddress"] = true + handleSettingRemoteAddrError(ctx, err, form) + return + } if u.User != nil && form.MirrorPassword == "" && form.MirrorUsername == u.User.Username() { form.MirrorPassword, _ = u.User.Password() } - address, err := forms.ParseRemoteAddr(form.MirrorAddress, form.MirrorUsername, form.MirrorPassword) - if err == nil { - err = migrations.IsMigrateURLAllowed(address, ctx.Doer) - } + err = migrations.IsMigrateURLAllowed(u.String(), ctx.Doer) if err != nil { ctx.Data["Err_MirrorAddress"] = true handleSettingRemoteAddrError(ctx, err, form) return } - if err := mirror_service.UpdateAddress(ctx, ctx.Repo.Mirror, address); err != nil { + if err := mirror_service.UpdateAddress(ctx, ctx.Repo.Mirror, u.String()); err != nil { ctx.ServerError("UpdateAddress", err) return } |