mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 08:42:32 -05:00
Fix migration context data (#14910)
* Unified context data. * Changed method name.
This commit is contained in:
parent
9b261f52f0
commit
40aca73347
1 changed files with 22 additions and 15 deletions
|
@ -32,8 +32,10 @@ func Migrate(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...)
|
||||
serviceType := ctx.QueryInt("service_type")
|
||||
serviceType := structs.GitServiceType(ctx.QueryInt("service_type"))
|
||||
|
||||
setMigrationContextData(ctx, serviceType)
|
||||
|
||||
if serviceType == 0 {
|
||||
ctx.Data["Org"] = ctx.Query("org")
|
||||
ctx.Data["Mirror"] = ctx.Query("mirror")
|
||||
|
@ -42,10 +44,7 @@ func Migrate(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Data["Title"] = ctx.Tr("new_migrate")
|
||||
ctx.Data["private"] = getRepoPrivate(ctx)
|
||||
ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
|
||||
ctx.Data["DisableMirrors"] = setting.Repository.DisableMirrors
|
||||
ctx.Data["mirror"] = ctx.Query("mirror") == "1"
|
||||
ctx.Data["wiki"] = ctx.Query("wiki") == "1"
|
||||
ctx.Data["milestones"] = ctx.Query("milestones") == "1"
|
||||
|
@ -53,9 +52,6 @@ func Migrate(ctx *context.Context) {
|
|||
ctx.Data["issues"] = ctx.Query("issues") == "1"
|
||||
ctx.Data["pull_requests"] = ctx.Query("pull_requests") == "1"
|
||||
ctx.Data["releases"] = ctx.Query("releases") == "1"
|
||||
ctx.Data["LFSActive"] = setting.LFS.StartServer
|
||||
// Plain git should be first
|
||||
ctx.Data["service"] = structs.GitServiceType(serviceType)
|
||||
|
||||
ctxUser := checkContextUser(ctx, ctx.QueryInt64("org"))
|
||||
if ctx.Written() {
|
||||
|
@ -63,7 +59,7 @@ func Migrate(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
ctx.HTML(200, base.TplName("repo/migrate/"+structs.GitServiceType(serviceType).Name()))
|
||||
ctx.HTML(200, base.TplName("repo/migrate/"+serviceType.Name()))
|
||||
}
|
||||
|
||||
func handleMigrateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form *auth.MigrateRepoForm) {
|
||||
|
@ -125,12 +121,9 @@ func MigratePost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Data["Title"] = ctx.Tr("new_migrate")
|
||||
// Plain git should be first
|
||||
ctx.Data["service"] = structs.GitServiceType(form.Service)
|
||||
ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...)
|
||||
serviceType := structs.GitServiceType(form.Service)
|
||||
|
||||
tpl := base.TplName("repo/migrate/" + structs.GitServiceType(form.Service).Name())
|
||||
setMigrationContextData(ctx, serviceType)
|
||||
|
||||
ctxUser := checkContextUser(ctx, form.UID)
|
||||
if ctx.Written() {
|
||||
|
@ -138,6 +131,8 @@ func MigratePost(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
tpl := base.TplName("repo/migrate/" + serviceType.Name())
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tpl)
|
||||
return
|
||||
|
@ -166,7 +161,7 @@ func MigratePost(ctx *context.Context) {
|
|||
|
||||
var opts = migrations.MigrateOptions{
|
||||
OriginalURL: form.CloneAddr,
|
||||
GitServiceType: structs.GitServiceType(form.Service),
|
||||
GitServiceType: serviceType,
|
||||
CloneAddr: remoteAddr,
|
||||
RepoName: form.RepoName,
|
||||
Description: form.Description,
|
||||
|
@ -206,3 +201,15 @@ func MigratePost(ctx *context.Context) {
|
|||
|
||||
handleMigrateError(ctx, ctxUser, err, "MigratePost", tpl, form)
|
||||
}
|
||||
|
||||
func setMigrationContextData(ctx *context.Context, serviceType structs.GitServiceType) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_migrate")
|
||||
|
||||
ctx.Data["LFSActive"] = setting.LFS.StartServer
|
||||
ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
|
||||
ctx.Data["DisableMirrors"] = setting.Repository.DisableMirrors
|
||||
|
||||
// Plain git should be first
|
||||
ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...)
|
||||
ctx.Data["service"] = serviceType
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue