|
|
@ -716,13 +716,27 @@ func EditPullRequest(ctx *context.APIContext) { |
|
|
|
ctx.Error(http.StatusPreconditionFailed, "MergedPRState", "cannot change state of this pull request, it was already merged") |
|
|
|
ctx.Error(http.StatusPreconditionFailed, "MergedPRState", "cannot change state of this pull request, it was already merged") |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if err := issue_service.ChangeStatus(ctx, issue, ctx.Doer, "", api.StateClosed == api.StateType(*form.State)); err != nil { |
|
|
|
|
|
|
|
if issues_model.IsErrDependenciesLeft(err) { |
|
|
|
var isClosed bool |
|
|
|
ctx.Error(http.StatusPreconditionFailed, "DependenciesLeft", "cannot close this pull request because it still has open dependencies") |
|
|
|
switch state := api.StateType(*form.State); state { |
|
|
|
|
|
|
|
case api.StateOpen: |
|
|
|
|
|
|
|
isClosed = false |
|
|
|
|
|
|
|
case api.StateClosed: |
|
|
|
|
|
|
|
isClosed = true |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
ctx.Error(http.StatusPreconditionFailed, "UnknownPRStateError", fmt.Sprintf("unknown state: %s", state)) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if issue.IsClosed != isClosed { |
|
|
|
|
|
|
|
if err := issue_service.ChangeStatus(ctx, issue, ctx.Doer, "", isClosed); err != nil { |
|
|
|
|
|
|
|
if issues_model.IsErrDependenciesLeft(err) { |
|
|
|
|
|
|
|
ctx.Error(http.StatusPreconditionFailed, "DependenciesLeft", "cannot close this pull request because it still has open dependencies") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx.Error(http.StatusInternalServerError, "ChangeStatus", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Error(http.StatusInternalServerError, "ChangeStatus", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|