@@ -1133,49 +1133,47 @@ func MergePullRequest(ctx *context.Context) {
1133
1133
switch {
1134
1134
case errors .Is (err , pull_service .ErrIsClosed ):
1135
1135
if issue .IsPull {
1136
- ctx .Flash . Error (ctx .Tr ("repo.pulls.is_closed" ))
1136
+ ctx .JSONError (ctx .Tr ("repo.pulls.is_closed" ))
1137
1137
} else {
1138
- ctx .Flash . Error (ctx .Tr ("repo.issues.closed_title" ))
1138
+ ctx .JSONError (ctx .Tr ("repo.issues.closed_title" ))
1139
1139
}
1140
1140
case errors .Is (err , pull_service .ErrUserNotAllowedToMerge ):
1141
- ctx .Flash . Error (ctx .Tr ("repo.pulls.update_not_allowed" ))
1141
+ ctx .JSONError (ctx .Tr ("repo.pulls.update_not_allowed" ))
1142
1142
case errors .Is (err , pull_service .ErrHasMerged ):
1143
- ctx .Flash . Error (ctx .Tr ("repo.pulls.has_merged" ))
1143
+ ctx .JSONError (ctx .Tr ("repo.pulls.has_merged" ))
1144
1144
case errors .Is (err , pull_service .ErrIsWorkInProgress ):
1145
- ctx .Flash . Error (ctx .Tr ("repo.pulls.no_merge_wip" ))
1145
+ ctx .JSONError (ctx .Tr ("repo.pulls.no_merge_wip" ))
1146
1146
case errors .Is (err , pull_service .ErrNotMergableState ):
1147
- ctx .Flash . Error (ctx .Tr ("repo.pulls.no_merge_not_ready" ))
1147
+ ctx .JSONError (ctx .Tr ("repo.pulls.no_merge_not_ready" ))
1148
1148
case models .IsErrDisallowedToMerge (err ):
1149
- ctx .Flash . Error (ctx .Tr ("repo.pulls.no_merge_not_ready" ))
1149
+ ctx .JSONError (ctx .Tr ("repo.pulls.no_merge_not_ready" ))
1150
1150
case asymkey_service .IsErrWontSign (err ):
1151
- ctx .Flash . Error (err .Error ()) // has no translation ...
1151
+ ctx .JSONError (err .Error ()) // has no translation ...
1152
1152
case errors .Is (err , pull_service .ErrDependenciesLeft ):
1153
- ctx .Flash . Error (ctx .Tr ("repo.issues.dependency.pr_close_blocked" ))
1153
+ ctx .JSONError (ctx .Tr ("repo.issues.dependency.pr_close_blocked" ))
1154
1154
default :
1155
1155
ctx .ServerError ("WebCheck" , err )
1156
- return
1157
1156
}
1158
1157
1159
- ctx .Redirect (issue .Link ())
1160
1158
return
1161
1159
}
1162
1160
1163
1161
// handle manually-merged mark
1164
1162
if manuallyMerged {
1165
1163
if err := pull_service .MergedManually (pr , ctx .Doer , ctx .Repo .GitRepo , form .MergeCommitID ); err != nil {
1166
1164
switch {
1167
-
1168
1165
case models .IsErrInvalidMergeStyle (err ):
1169
- ctx .Flash . Error (ctx .Tr ("repo.pulls.invalid_merge_option" ))
1166
+ ctx .JSONError (ctx .Tr ("repo.pulls.invalid_merge_option" ))
1170
1167
case strings .Contains (err .Error (), "Wrong commit ID" ):
1171
- ctx .Flash . Error (ctx .Tr ("repo.pulls.wrong_commit_id" ))
1168
+ ctx .JSONError (ctx .Tr ("repo.pulls.wrong_commit_id" ))
1172
1169
default :
1173
1170
ctx .ServerError ("MergedManually" , err )
1174
- return
1175
1171
}
1172
+
1173
+ return
1176
1174
}
1177
1175
1178
- ctx .Redirect (issue .Link ())
1176
+ ctx .JSONRedirect (issue .Link ())
1179
1177
return
1180
1178
}
1181
1179
@@ -1205,15 +1203,14 @@ func MergePullRequest(ctx *context.Context) {
1205
1203
} else if scheduled {
1206
1204
// nothing more to do ...
1207
1205
ctx .Flash .Success (ctx .Tr ("repo.pulls.auto_merge_newly_scheduled" ))
1208
- ctx .Redirect (fmt .Sprintf ("%s/pulls/%d" , ctx .Repo .RepoLink , pr .Index ))
1206
+ ctx .JSONRedirect (fmt .Sprintf ("%s/pulls/%d" , ctx .Repo .RepoLink , pr .Index ))
1209
1207
return
1210
1208
}
1211
1209
}
1212
1210
1213
1211
if err := pull_service .Merge (ctx , pr , ctx .Doer , ctx .Repo .GitRepo , repo_model .MergeStyle (form .Do ), form .HeadCommitID , message , false ); err != nil {
1214
1212
if models .IsErrInvalidMergeStyle (err ) {
1215
- ctx .Flash .Error (ctx .Tr ("repo.pulls.invalid_merge_option" ))
1216
- ctx .Redirect (issue .Link ())
1213
+ ctx .JSONError (ctx .Tr ("repo.pulls.invalid_merge_option" ))
1217
1214
} else if models .IsErrMergeConflicts (err ) {
1218
1215
conflictError := err .(models.ErrMergeConflicts )
1219
1216
flashError , err := ctx .RenderToString (tplAlertDetails , map [string ]any {
@@ -1226,7 +1223,7 @@ func MergePullRequest(ctx *context.Context) {
1226
1223
return
1227
1224
}
1228
1225
ctx .Flash .Error (flashError )
1229
- ctx .Redirect (issue .Link ())
1226
+ ctx .JSONRedirect (issue .Link ())
1230
1227
} else if models .IsErrRebaseConflicts (err ) {
1231
1228
conflictError := err .(models.ErrRebaseConflicts )
1232
1229
flashError , err := ctx .RenderToString (tplAlertDetails , map [string ]any {
@@ -1270,7 +1267,7 @@ func MergePullRequest(ctx *context.Context) {
1270
1267
}
1271
1268
ctx .Flash .Error (flashError )
1272
1269
}
1273
- ctx .Redirect (issue .Link ())
1270
+ ctx .JSONRedirect (issue .Link ())
1274
1271
} else {
1275
1272
ctx .ServerError ("Merge" , err )
1276
1273
}
@@ -1279,7 +1276,7 @@ func MergePullRequest(ctx *context.Context) {
1279
1276
log .Trace ("Pull request merged: %d" , pr .ID )
1280
1277
1281
1278
if err := stopTimerIfAvailable (ctx , ctx .Doer , issue ); err != nil {
1282
- ctx .ServerError ("CreateOrStopIssueStopwatch " , err )
1279
+ ctx .ServerError ("stopTimerIfAvailable " , err )
1283
1280
return
1284
1281
}
1285
1282
@@ -1293,7 +1290,7 @@ func MergePullRequest(ctx *context.Context) {
1293
1290
return
1294
1291
}
1295
1292
if exist {
1296
- ctx .Redirect (issue .Link ())
1293
+ ctx .JSONRedirect (issue .Link ())
1297
1294
return
1298
1295
}
1299
1296
@@ -1311,7 +1308,7 @@ func MergePullRequest(ctx *context.Context) {
1311
1308
deleteBranch (ctx , pr , headRepo )
1312
1309
}
1313
1310
1314
- ctx .Redirect (issue .Link ())
1311
+ ctx .JSONRedirect (issue .Link ())
1315
1312
}
1316
1313
1317
1314
// CancelAutoMergePullRequest cancels a scheduled pr
0 commit comments