@@ -1149,49 +1149,47 @@ func MergePullRequest(ctx *context.Context) {
1149
1149
switch {
1150
1150
case errors .Is (err , pull_service .ErrIsClosed ):
1151
1151
if issue .IsPull {
1152
- ctx .Flash . Error (ctx .Tr ("repo.pulls.is_closed" ))
1152
+ ctx .JSONError (ctx .Tr ("repo.pulls.is_closed" ))
1153
1153
} else {
1154
- ctx .Flash . Error (ctx .Tr ("repo.issues.closed_title" ))
1154
+ ctx .JSONError (ctx .Tr ("repo.issues.closed_title" ))
1155
1155
}
1156
1156
case errors .Is (err , pull_service .ErrUserNotAllowedToMerge ):
1157
- ctx .Flash . Error (ctx .Tr ("repo.pulls.update_not_allowed" ))
1157
+ ctx .JSONError (ctx .Tr ("repo.pulls.update_not_allowed" ))
1158
1158
case errors .Is (err , pull_service .ErrHasMerged ):
1159
- ctx .Flash . Error (ctx .Tr ("repo.pulls.has_merged" ))
1159
+ ctx .JSONError (ctx .Tr ("repo.pulls.has_merged" ))
1160
1160
case errors .Is (err , pull_service .ErrIsWorkInProgress ):
1161
- ctx .Flash . Error (ctx .Tr ("repo.pulls.no_merge_wip" ))
1161
+ ctx .JSONError (ctx .Tr ("repo.pulls.no_merge_wip" ))
1162
1162
case errors .Is (err , pull_service .ErrNotMergableState ):
1163
- ctx .Flash . Error (ctx .Tr ("repo.pulls.no_merge_not_ready" ))
1163
+ ctx .JSONError (ctx .Tr ("repo.pulls.no_merge_not_ready" ))
1164
1164
case models .IsErrDisallowedToMerge (err ):
1165
- ctx .Flash . Error (ctx .Tr ("repo.pulls.no_merge_not_ready" ))
1165
+ ctx .JSONError (ctx .Tr ("repo.pulls.no_merge_not_ready" ))
1166
1166
case asymkey_service .IsErrWontSign (err ):
1167
- ctx .Flash . Error (err .Error ()) // has no translation ...
1167
+ ctx .JSONError (err .Error ()) // has no translation ...
1168
1168
case errors .Is (err , pull_service .ErrDependenciesLeft ):
1169
- ctx .Flash . Error (ctx .Tr ("repo.issues.dependency.pr_close_blocked" ))
1169
+ ctx .JSONError (ctx .Tr ("repo.issues.dependency.pr_close_blocked" ))
1170
1170
default :
1171
1171
ctx .ServerError ("WebCheck" , err )
1172
- return
1173
1172
}
1174
1173
1175
- ctx .Redirect (issue .Link ())
1176
1174
return
1177
1175
}
1178
1176
1179
1177
// handle manually-merged mark
1180
1178
if manuallyMerged {
1181
1179
if err := pull_service .MergedManually (ctx , pr , ctx .Doer , ctx .Repo .GitRepo , form .MergeCommitID ); err != nil {
1182
1180
switch {
1183
-
1184
1181
case models .IsErrInvalidMergeStyle (err ):
1185
- ctx .Flash . Error (ctx .Tr ("repo.pulls.invalid_merge_option" ))
1182
+ ctx .JSONError (ctx .Tr ("repo.pulls.invalid_merge_option" ))
1186
1183
case strings .Contains (err .Error (), "Wrong commit ID" ):
1187
- ctx .Flash . Error (ctx .Tr ("repo.pulls.wrong_commit_id" ))
1184
+ ctx .JSONError (ctx .Tr ("repo.pulls.wrong_commit_id" ))
1188
1185
default :
1189
1186
ctx .ServerError ("MergedManually" , err )
1190
- return
1191
1187
}
1188
+
1189
+ return
1192
1190
}
1193
1191
1194
- ctx .Redirect (issue .Link ())
1192
+ ctx .JSONRedirect (issue .Link ())
1195
1193
return
1196
1194
}
1197
1195
@@ -1221,15 +1219,14 @@ func MergePullRequest(ctx *context.Context) {
1221
1219
} else if scheduled {
1222
1220
// nothing more to do ...
1223
1221
ctx .Flash .Success (ctx .Tr ("repo.pulls.auto_merge_newly_scheduled" ))
1224
- ctx .Redirect (fmt .Sprintf ("%s/pulls/%d" , ctx .Repo .RepoLink , pr .Index ))
1222
+ ctx .JSONRedirect (fmt .Sprintf ("%s/pulls/%d" , ctx .Repo .RepoLink , pr .Index ))
1225
1223
return
1226
1224
}
1227
1225
}
1228
1226
1229
1227
if err := pull_service .Merge (ctx , pr , ctx .Doer , ctx .Repo .GitRepo , repo_model .MergeStyle (form .Do ), form .HeadCommitID , message , false ); err != nil {
1230
1228
if models .IsErrInvalidMergeStyle (err ) {
1231
- ctx .Flash .Error (ctx .Tr ("repo.pulls.invalid_merge_option" ))
1232
- ctx .Redirect (issue .Link ())
1229
+ ctx .JSONError (ctx .Tr ("repo.pulls.invalid_merge_option" ))
1233
1230
} else if models .IsErrMergeConflicts (err ) {
1234
1231
conflictError := err .(models.ErrMergeConflicts )
1235
1232
flashError , err := ctx .RenderToString (tplAlertDetails , map [string ]any {
@@ -1242,7 +1239,7 @@ func MergePullRequest(ctx *context.Context) {
1242
1239
return
1243
1240
}
1244
1241
ctx .Flash .Error (flashError )
1245
- ctx .Redirect (issue .Link ())
1242
+ ctx .JSONRedirect (issue .Link ())
1246
1243
} else if models .IsErrRebaseConflicts (err ) {
1247
1244
conflictError := err .(models.ErrRebaseConflicts )
1248
1245
flashError , err := ctx .RenderToString (tplAlertDetails , map [string ]any {
@@ -1286,7 +1283,7 @@ func MergePullRequest(ctx *context.Context) {
1286
1283
}
1287
1284
ctx .Flash .Error (flashError )
1288
1285
}
1289
- ctx .Redirect (issue .Link ())
1286
+ ctx .JSONRedirect (issue .Link ())
1290
1287
} else {
1291
1288
ctx .ServerError ("Merge" , err )
1292
1289
}
@@ -1295,7 +1292,7 @@ func MergePullRequest(ctx *context.Context) {
1295
1292
log .Trace ("Pull request merged: %d" , pr .ID )
1296
1293
1297
1294
if err := stopTimerIfAvailable (ctx , ctx .Doer , issue ); err != nil {
1298
- ctx .ServerError ("CreateOrStopIssueStopwatch " , err )
1295
+ ctx .ServerError ("stopTimerIfAvailable " , err )
1299
1296
return
1300
1297
}
1301
1298
@@ -1309,7 +1306,7 @@ func MergePullRequest(ctx *context.Context) {
1309
1306
return
1310
1307
}
1311
1308
if exist {
1312
- ctx .Redirect (issue .Link ())
1309
+ ctx .JSONRedirect (issue .Link ())
1313
1310
return
1314
1311
}
1315
1312
@@ -1327,7 +1324,7 @@ func MergePullRequest(ctx *context.Context) {
1327
1324
deleteBranch (ctx , pr , headRepo )
1328
1325
}
1329
1326
1330
- ctx .Redirect (issue .Link ())
1327
+ ctx .JSONRedirect (issue .Link ())
1331
1328
}
1332
1329
1333
1330
// CancelAutoMergePullRequest cancels a scheduled pr
0 commit comments