@ -1133,30 +1133,28 @@ func MergePullRequest(ctx *context.Context) {
switch {
switch {
case errors . Is ( err , pull_service . ErrIsClosed ) :
case errors . Is ( err , pull_service . ErrIsClosed ) :
if issue . IsPull {
if issue . IsPull {
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.is_closed" ) )
ctx . JSON Error( ctx . Tr ( "repo.pulls.is_closed" ) )
} else {
} else {
ctx . Flash . Error ( ctx . Tr ( "repo.issues.closed_title" ) )
ctx . JSON Error( ctx . Tr ( "repo.issues.closed_title" ) )
}
}
case errors . Is ( err , pull_service . ErrUserNotAllowedToMerge ) :
case errors . Is ( err , pull_service . ErrUserNotAllowedToMerge ) :
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.update_not_allowed" ) )
ctx . JSON Error( ctx . Tr ( "repo.pulls.update_not_allowed" ) )
case errors . Is ( err , pull_service . ErrHasMerged ) :
case errors . Is ( err , pull_service . ErrHasMerged ) :
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.has_merged" ) )
ctx . JSON Error( ctx . Tr ( "repo.pulls.has_merged" ) )
case errors . Is ( err , pull_service . ErrIsWorkInProgress ) :
case errors . Is ( err , pull_service . ErrIsWorkInProgress ) :
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.no_merge_wip" ) )
ctx . JSON Error( ctx . Tr ( "repo.pulls.no_merge_wip" ) )
case errors . Is ( err , pull_service . ErrNotMergableState ) :
case errors . Is ( err , pull_service . ErrNotMergableState ) :
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.no_merge_not_ready" ) )
ctx . JSON Error( ctx . Tr ( "repo.pulls.no_merge_not_ready" ) )
case models . IsErrDisallowedToMerge ( err ) :
case models . IsErrDisallowedToMerge ( err ) :
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.no_merge_not_ready" ) )
ctx . JSON Error( ctx . Tr ( "repo.pulls.no_merge_not_ready" ) )
case asymkey_service . IsErrWontSign ( err ) :
case asymkey_service . IsErrWontSign ( err ) :
ctx . Flash . Error ( err . Error ( ) ) // has no translation ...
ctx . JSON Error( err . Error ( ) ) // has no translation ...
case errors . Is ( err , pull_service . ErrDependenciesLeft ) :
case errors . Is ( err , pull_service . ErrDependenciesLeft ) :
ctx . Flash . Error ( ctx . Tr ( "repo.issues.dependency.pr_close_blocked" ) )
ctx . JSON Error( ctx . Tr ( "repo.issues.dependency.pr_close_blocked" ) )
default :
default :
ctx . ServerError ( "WebCheck" , err )
ctx . ServerError ( "WebCheck" , err )
return
}
}
ctx . Redirect ( issue . Link ( ) )
return
return
}
}
@ -1164,18 +1162,18 @@ func MergePullRequest(ctx *context.Context) {
if manuallyMerged {
if manuallyMerged {
if err := pull_service . MergedManually ( pr , ctx . Doer , ctx . Repo . GitRepo , form . MergeCommitID ) ; err != nil {
if err := pull_service . MergedManually ( pr , ctx . Doer , ctx . Repo . GitRepo , form . MergeCommitID ) ; err != nil {
switch {
switch {
case models . IsErrInvalidMergeStyle ( err ) :
case models . IsErrInvalidMergeStyle ( err ) :
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.invalid_merge_option" ) )
ctx . JSON Error( ctx . Tr ( "repo.pulls.invalid_merge_option" ) )
case strings . Contains ( err . Error ( ) , "Wrong commit ID" ) :
case strings . Contains ( err . Error ( ) , "Wrong commit ID" ) :
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.wrong_commit_id" ) )
ctx . JSON Error( ctx . Tr ( "repo.pulls.wrong_commit_id" ) )
default :
default :
ctx . ServerError ( "MergedManually" , err )
ctx . ServerError ( "MergedManually" , err )
return
}
}
return
}
}
ctx . Redirect ( issue . Link ( ) )
ctx . JSON Redirect( issue . Link ( ) )
return
return
}
}
@ -1205,15 +1203,14 @@ func MergePullRequest(ctx *context.Context) {
} else if scheduled {
} else if scheduled {
// nothing more to do ...
// nothing more to do ...
ctx . Flash . Success ( ctx . Tr ( "repo.pulls.auto_merge_newly_scheduled" ) )
ctx . Flash . Success ( ctx . Tr ( "repo.pulls.auto_merge_newly_scheduled" ) )
ctx . Redirect ( fmt . Sprintf ( "%s/pulls/%d" , ctx . Repo . RepoLink , pr . Index ) )
ctx . JSON Redirect( fmt . Sprintf ( "%s/pulls/%d" , ctx . Repo . RepoLink , pr . Index ) )
return
return
}
}
}
}
if err := pull_service . Merge ( ctx , pr , ctx . Doer , ctx . Repo . GitRepo , repo_model . MergeStyle ( form . Do ) , form . HeadCommitID , message , false ) ; err != nil {
if err := pull_service . Merge ( ctx , pr , ctx . Doer , ctx . Repo . GitRepo , repo_model . MergeStyle ( form . Do ) , form . HeadCommitID , message , false ) ; err != nil {
if models . IsErrInvalidMergeStyle ( err ) {
if models . IsErrInvalidMergeStyle ( err ) {
ctx . Flash . Error ( ctx . Tr ( "repo.pulls.invalid_merge_option" ) )
ctx . JSONError ( ctx . Tr ( "repo.pulls.invalid_merge_option" ) )
ctx . Redirect ( issue . Link ( ) )
} else if models . IsErrMergeConflicts ( err ) {
} else if models . IsErrMergeConflicts ( err ) {
conflictError := err . ( models . ErrMergeConflicts )
conflictError := err . ( models . ErrMergeConflicts )
flashError , err := ctx . RenderToString ( tplAlertDetails , map [ string ] any {
flashError , err := ctx . RenderToString ( tplAlertDetails , map [ string ] any {
@ -1226,7 +1223,7 @@ func MergePullRequest(ctx *context.Context) {
return
return
}
}
ctx . Flash . Error ( flashError )
ctx . Flash . Error ( flashError )
ctx . Redirect ( issue . Link ( ) )
ctx . JSON Redirect( issue . Link ( ) )
} else if models . IsErrRebaseConflicts ( err ) {
} else if models . IsErrRebaseConflicts ( err ) {
conflictError := err . ( models . ErrRebaseConflicts )
conflictError := err . ( models . ErrRebaseConflicts )
flashError , err := ctx . RenderToString ( tplAlertDetails , map [ string ] any {
flashError , err := ctx . RenderToString ( tplAlertDetails , map [ string ] any {
@ -1270,7 +1267,7 @@ func MergePullRequest(ctx *context.Context) {
}
}
ctx . Flash . Error ( flashError )
ctx . Flash . Error ( flashError )
}
}
ctx . Redirect ( issue . Link ( ) )
ctx . JSON Redirect( issue . Link ( ) )
} else {
} else {
ctx . ServerError ( "Merge" , err )
ctx . ServerError ( "Merge" , err )
}
}
@ -1279,7 +1276,7 @@ func MergePullRequest(ctx *context.Context) {
log . Trace ( "Pull request merged: %d" , pr . ID )
log . Trace ( "Pull request merged: %d" , pr . ID )
if err := stopTimerIfAvailable ( ctx , ctx . Doer , issue ) ; err != nil {
if err := stopTimerIfAvailable ( ctx , ctx . Doer , issue ) ; err != nil {
ctx . ServerError ( "CreateOrStopIssueStopwatch " , err )
ctx . ServerError ( "stopTimerIfAvailable " , err )
return
return
}
}
@ -1293,7 +1290,7 @@ func MergePullRequest(ctx *context.Context) {
return
return
}
}
if exist {
if exist {
ctx . Redirect ( issue . Link ( ) )
ctx . JSON Redirect( issue . Link ( ) )
return
return
}
}
@ -1311,7 +1308,7 @@ func MergePullRequest(ctx *context.Context) {
deleteBranch ( ctx , pr , headRepo )
deleteBranch ( ctx , pr , headRepo )
}
}
ctx . Redirect ( issue . Link ( ) )
ctx . JSON Redirect( issue . Link ( ) )
}
}
// CancelAutoMergePullRequest cancels a scheduled pr
// CancelAutoMergePullRequest cancels a scheduled pr