diff options
author | zeripath <art27@cantab.net> | 2020-09-23 21:25:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-23 15:25:46 -0500 |
commit | 3f522cdaad6e8ca30aefbb642cc88dfedcc94495 (patch) | |
tree | ca3361e061aebd832fdb5e9787f18b205d6915cc /routers/repo/migrate.go | |
parent | f215e015df7d03684ecab28e3a27d24620d5c8a2 (diff) | |
download | gitea-3f522cdaad6e8ca30aefbb642cc88dfedcc94495.tar.gz gitea-3f522cdaad6e8ca30aefbb642cc88dfedcc94495.zip |
Fix handling of migration errors (#12928)
* Fix handling of migration errors
The migration type selection screen PR did not correctly handle errors
and any user input error on the migration page would simply redirect
back to the selection page. This meant that the error would simply be
lost and the user would be none the wiser as to what happened.
Signed-off-by: Andrew Thornton <art27@cantab.net>
* make gen-swagger
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers/repo/migrate.go')
-rw-r--r-- | routers/repo/migrate.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/routers/repo/migrate.go b/routers/repo/migrate.go index 34060aabde..19dbfbab40 100644 --- a/routers/repo/migrate.go +++ b/routers/repo/migrate.go @@ -94,9 +94,11 @@ func handleMigrateError(ctx *context.Context, owner *models.User, err error, nam func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { ctx.Data["Title"] = ctx.Tr("new_migrate") // Plain git should be first - ctx.Data["service"] = form.Service + ctx.Data["service"] = structs.GitServiceType(form.Service) ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...) + tpl := base.TplName("repo/migrate/" + structs.GitServiceType(form.Service).Name()) + ctxUser := checkContextUser(ctx, form.UID) if ctx.Written() { return @@ -104,7 +106,7 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { ctx.Data["ContextUser"] = ctxUser if ctx.HasError() { - ctx.HTML(200, tplMigrate) + ctx.HTML(200, tpl) return } @@ -115,11 +117,11 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { addrErr := err.(models.ErrInvalidCloneAddr) switch { case addrErr.IsURLError: - ctx.RenderWithErr(ctx.Tr("form.url_error"), tplMigrate, &form) + ctx.RenderWithErr(ctx.Tr("form.url_error"), tpl, &form) case addrErr.IsPermissionDenied: - ctx.RenderWithErr(ctx.Tr("repo.migrate.permission_denied"), tplMigrate, &form) + ctx.RenderWithErr(ctx.Tr("repo.migrate.permission_denied"), tpl, &form) case addrErr.IsInvalidPath: - ctx.RenderWithErr(ctx.Tr("repo.migrate.invalid_local_path"), tplMigrate, &form) + ctx.RenderWithErr(ctx.Tr("repo.migrate.invalid_local_path"), tpl, &form) default: ctx.ServerError("Unknown error", err) } @@ -159,7 +161,7 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { err = models.CheckCreateRepository(ctx.User, ctxUser, opts.RepoName) if err != nil { - handleMigrateError(ctx, ctxUser, err, "MigratePost", tplMigrate, &form) + handleMigrateError(ctx, ctxUser, err, "MigratePost", tpl, &form) return } @@ -169,5 +171,5 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { return } - handleMigrateError(ctx, ctxUser, err, "MigratePost", tplMigrate, &form) + handleMigrateError(ctx, ctxUser, err, "MigratePost", tpl, &form) } |