@@ -37,7 +37,6 @@ import (
37
37
"code.gitea.io/gitea/modules/upload"
38
38
"code.gitea.io/gitea/modules/util"
39
39
"code.gitea.io/gitea/modules/web"
40
- "code.gitea.io/gitea/modules/web/middleware"
41
40
"code.gitea.io/gitea/routers/utils"
42
41
asymkey_service "code.gitea.io/gitea/services/asymkey"
43
42
"code.gitea.io/gitea/services/automerge"
@@ -1206,36 +1205,12 @@ func CompareAndPullRequestPost(ctx *context.Context) {
1206
1205
}
1207
1206
1208
1207
if ctx .HasError () {
1209
- middleware .AssignForm (form , ctx .Data )
1210
-
1211
- // This stage is already stop creating new pull request, so it does not matter if it has
1212
- // something to compare or not.
1213
- PrepareCompareDiff (ctx , ci ,
1214
- gitdiff .GetWhitespaceFlag (ctx .Data ["WhitespaceBehavior" ].(string )))
1215
- if ctx .Written () {
1216
- return
1217
- }
1218
-
1219
- if len (form .Title ) > 255 {
1220
- var trailer string
1221
- form .Title , trailer = util .SplitStringAtByteN (form .Title , 255 )
1222
-
1223
- form .Content = trailer + "\n \n " + form .Content
1224
- }
1225
- middleware .AssignForm (form , ctx .Data )
1226
-
1227
- ctx .HTML (http .StatusOK , tplCompareDiff )
1208
+ ctx .JSONError (ctx .GetErrMsg ())
1228
1209
return
1229
1210
}
1230
1211
1231
1212
if util .IsEmptyString (form .Title ) {
1232
- PrepareCompareDiff (ctx , ci ,
1233
- gitdiff .GetWhitespaceFlag (ctx .Data ["WhitespaceBehavior" ].(string )))
1234
- if ctx .Written () {
1235
- return
1236
- }
1237
-
1238
- ctx .RenderWithErr (ctx .Tr ("repo.issues.new.title_empty" ), tplCompareDiff , form )
1213
+ ctx .JSONError (ctx .Tr ("repo.issues.new.title_empty" ))
1239
1214
return
1240
1215
}
1241
1216
@@ -1278,28 +1253,28 @@ func CompareAndPullRequestPost(ctx *context.Context) {
1278
1253
pushrejErr := err .(* git.ErrPushRejected )
1279
1254
message := pushrejErr .Message
1280
1255
if len (message ) == 0 {
1281
- ctx .Flash .Error (ctx .Tr ("repo.pulls.push_rejected_no_message" ))
1282
- } else {
1283
- flashError , err := ctx .RenderToString (tplAlertDetails , map [string ]interface {}{
1284
- "Message" : ctx .Tr ("repo.pulls.push_rejected" ),
1285
- "Summary" : ctx .Tr ("repo.pulls.push_rejected_summary" ),
1286
- "Details" : utils .SanitizeFlashErrorString (pushrejErr .Message ),
1287
- })
1288
- if err != nil {
1289
- ctx .ServerError ("CompareAndPullRequest.HTMLString" , err )
1290
- return
1291
- }
1292
- ctx .Flash .Error (flashError )
1256
+ ctx .JSONError (ctx .Tr ("repo.pulls.push_rejected_no_message" ))
1257
+ return
1293
1258
}
1294
- ctx .Redirect (pullIssue .Link ())
1259
+ flashError , err := ctx .RenderToString (tplAlertDetails , map [string ]interface {}{
1260
+ "Message" : ctx .Tr ("repo.pulls.push_rejected" ),
1261
+ "Summary" : ctx .Tr ("repo.pulls.push_rejected_summary" ),
1262
+ "Details" : utils .SanitizeFlashErrorString (pushrejErr .Message ),
1263
+ })
1264
+ if err != nil {
1265
+ ctx .ServerError ("CompareAndPullRequest.HTMLString" , err )
1266
+ return
1267
+ }
1268
+ ctx .Flash .Error (flashError )
1269
+ ctx .JSONRedirect (pullIssue .Link ()) // FIXME: it's unfriendly, and will make the content lost
1295
1270
return
1296
1271
}
1297
1272
ctx .ServerError ("NewPullRequest" , err )
1298
1273
return
1299
1274
}
1300
1275
1301
1276
log .Trace ("Pull request created: %d/%d" , repo .ID , pullIssue .ID )
1302
- ctx .Redirect (pullIssue .Link ())
1277
+ ctx .JSONRedirect (pullIssue .Link ())
1303
1278
}
1304
1279
1305
1280
// CleanUpPullRequest responses for delete merged branch when PR has been merged
0 commit comments