@ -94,9 +94,11 @@ func handleMigrateError(ctx *context.Context, owner *models.User, err error, nam
func MigratePost ( ctx * context . Context , form auth . MigrateRepoForm ) {
func MigratePost ( ctx * context . Context , form auth . MigrateRepoForm ) {
ctx . Data [ "Title" ] = ctx . Tr ( "new_migrate" )
ctx . Data [ "Title" ] = ctx . Tr ( "new_migrate" )
// Plain git should be first
// 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 ... )
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 )
ctxUser := checkContextUser ( ctx , form . UID )
if ctx . Written ( ) {
if ctx . Written ( ) {
return
return
@ -104,7 +106,7 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
ctx . Data [ "ContextUser" ] = ctxUser
ctx . Data [ "ContextUser" ] = ctxUser
if ctx . HasError ( ) {
if ctx . HasError ( ) {
ctx . HTML ( 200 , tplMigrate )
ctx . HTML ( 200 , tpl )
return
return
}
}
@ -115,11 +117,11 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
addrErr := err . ( models . ErrInvalidCloneAddr )
addrErr := err . ( models . ErrInvalidCloneAddr )
switch {
switch {
case addrErr . IsURLError :
case addrErr . IsURLError :
ctx . RenderWithErr ( ctx . Tr ( "form.url_error" ) , tplMigrate , & form )
ctx . RenderWithErr ( ctx . Tr ( "form.url_error" ) , tpl , & form )
case addrErr . IsPermissionDenied :
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 :
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 :
default :
ctx . ServerError ( "Unknown error" , err )
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 )
err = models . CheckCreateRepository ( ctx . User , ctxUser , opts . RepoName )
if err != nil {
if err != nil {
handleMigrateError ( ctx , ctxUser , err , "MigratePost" , tplMigrate , & form )
handleMigrateError ( ctx , ctxUser , err , "MigratePost" , tpl , & form )
return
return
}
}
@ -169,5 +171,5 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
return
return
}
}
handleMigrateError ( ctx , ctxUser , err , "MigratePost" , tplMigrate , & form )
handleMigrateError ( ctx , ctxUser , err , "MigratePost" , tpl , & form )
}
}