@@ -32,8 +32,10 @@ func Migrate(ctx *context.Context) {
32
32
return
33
33
}
34
34
35
- ctx .Data ["Services" ] = append ([]structs.GitServiceType {structs .PlainGitService }, structs .SupportedFullGitService ... )
36
- serviceType := ctx .QueryInt ("service_type" )
35
+ serviceType := structs .GitServiceType (ctx .QueryInt ("service_type" ))
36
+
37
+ setMigrationContextData (ctx , serviceType )
38
+
37
39
if serviceType == 0 {
38
40
ctx .Data ["Org" ] = ctx .Query ("org" )
39
41
ctx .Data ["Mirror" ] = ctx .Query ("mirror" )
@@ -42,28 +44,22 @@ func Migrate(ctx *context.Context) {
42
44
return
43
45
}
44
46
45
- ctx .Data ["Title" ] = ctx .Tr ("new_migrate" )
46
47
ctx .Data ["private" ] = getRepoPrivate (ctx )
47
- ctx .Data ["IsForcedPrivate" ] = setting .Repository .ForcePrivate
48
- ctx .Data ["DisableMirrors" ] = setting .Repository .DisableMirrors
49
48
ctx .Data ["mirror" ] = ctx .Query ("mirror" ) == "1"
50
49
ctx .Data ["wiki" ] = ctx .Query ("wiki" ) == "1"
51
50
ctx .Data ["milestones" ] = ctx .Query ("milestones" ) == "1"
52
51
ctx .Data ["labels" ] = ctx .Query ("labels" ) == "1"
53
52
ctx .Data ["issues" ] = ctx .Query ("issues" ) == "1"
54
53
ctx .Data ["pull_requests" ] = ctx .Query ("pull_requests" ) == "1"
55
54
ctx .Data ["releases" ] = ctx .Query ("releases" ) == "1"
56
- ctx .Data ["LFSActive" ] = setting .LFS .StartServer
57
- // Plain git should be first
58
- ctx .Data ["service" ] = structs .GitServiceType (serviceType )
59
55
60
56
ctxUser := checkContextUser (ctx , ctx .QueryInt64 ("org" ))
61
57
if ctx .Written () {
62
58
return
63
59
}
64
60
ctx .Data ["ContextUser" ] = ctxUser
65
61
66
- ctx .HTML (200 , base .TplName ("repo/migrate/" + structs . GitServiceType ( serviceType ) .Name ()))
62
+ ctx .HTML (200 , base .TplName ("repo/migrate/" + serviceType .Name ()))
67
63
}
68
64
69
65
func handleMigrateError (ctx * context.Context , owner * models.User , err error , name string , tpl base.TplName , form * auth.MigrateRepoForm ) {
@@ -125,19 +121,18 @@ func MigratePost(ctx *context.Context) {
125
121
return
126
122
}
127
123
128
- ctx .Data ["Title" ] = ctx .Tr ("new_migrate" )
129
- // Plain git should be first
130
- ctx .Data ["service" ] = structs .GitServiceType (form .Service )
131
- ctx .Data ["Services" ] = append ([]structs.GitServiceType {structs .PlainGitService }, structs .SupportedFullGitService ... )
124
+ serviceType := structs .GitServiceType (form .Service )
132
125
133
- tpl := base . TplName ( "repo/migrate/" + structs . GitServiceType ( form . Service ). Name () )
126
+ setMigrationContextData ( ctx , serviceType )
134
127
135
128
ctxUser := checkContextUser (ctx , form .UID )
136
129
if ctx .Written () {
137
130
return
138
131
}
139
132
ctx .Data ["ContextUser" ] = ctxUser
140
133
134
+ tpl := base .TplName ("repo/migrate/" + serviceType .Name ())
135
+
141
136
if ctx .HasError () {
142
137
ctx .HTML (200 , tpl )
143
138
return
@@ -166,7 +161,7 @@ func MigratePost(ctx *context.Context) {
166
161
167
162
var opts = migrations.MigrateOptions {
168
163
OriginalURL : form .CloneAddr ,
169
- GitServiceType : structs . GitServiceType ( form . Service ) ,
164
+ GitServiceType : serviceType ,
170
165
CloneAddr : remoteAddr ,
171
166
RepoName : form .RepoName ,
172
167
Description : form .Description ,
@@ -206,3 +201,15 @@ func MigratePost(ctx *context.Context) {
206
201
207
202
handleMigrateError (ctx , ctxUser , err , "MigratePost" , tpl , form )
208
203
}
204
+
205
+ func setMigrationContextData (ctx * context.Context , serviceType structs.GitServiceType ) {
206
+ ctx .Data ["Title" ] = ctx .Tr ("new_migrate" )
207
+
208
+ ctx .Data ["LFSActive" ] = setting .LFS .StartServer
209
+ ctx .Data ["IsForcedPrivate" ] = setting .Repository .ForcePrivate
210
+ ctx .Data ["DisableMirrors" ] = setting .Repository .DisableMirrors
211
+
212
+ // Plain git should be first
213
+ ctx .Data ["Services" ] = append ([]structs.GitServiceType {structs .PlainGitService }, structs .SupportedFullGitService ... )
214
+ ctx .Data ["service" ] = serviceType
215
+ }
0 commit comments