diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 1169ceaf6..df4bdf624 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -14,6 +14,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + "net/http" ) // ListIssues list the issues of a repository @@ -174,7 +175,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { if form.Closed { if err := issue.ChangeStatus(ctx.User, ctx.Repo.Repository, true); err != nil { if models.IsErrDependenciesLeft(err) { - ctx.Error(409, "", fmt.Sprintf("cannot close this issue because it still has open dependencies")) + ctx.Error(http.StatusPreconditionFailed, "", fmt.Sprintf("cannot close this issue because it still has open dependencies")) return } ctx.Error(500, "ChangeStatus", err) @@ -285,7 +286,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { if form.State != nil { if err = issue.ChangeStatus(ctx.User, ctx.Repo.Repository, api.StateClosed == api.StateType(*form.State)); err != nil { if models.IsErrDependenciesLeft(err) { - ctx.Error(409, "", fmt.Sprintf("cannot close this issue because it still has open dependencies")) + ctx.Error(http.StatusPreconditionFailed, "", fmt.Sprintf("cannot close this issue because it still has open dependencies")) return } ctx.Error(500, "ChangeStatus", err) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 0823edbd5..ef7edb737 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -15,6 +15,7 @@ import ( "code.gitea.io/gitea/modules/log" api "code.gitea.io/sdk/gitea" + "net/http" ) // ListPullRequests returns a list of all PRs @@ -367,7 +368,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { if form.State != nil { if err = issue.ChangeStatus(ctx.User, ctx.Repo.Repository, api.StateClosed == api.StateType(*form.State)); err != nil { if models.IsErrDependenciesLeft(err) { - ctx.Error(409, "", fmt.Sprintf("cannot close this pull request because it still has open dependencies")) + ctx.Error(http.StatusPreconditionFailed, "", fmt.Sprintf("cannot close this pull request because it still has open dependencies")) return } ctx.Error(500, "ChangeStatus", err) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index a2d8b8805..7efdb96cc 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -28,6 +28,7 @@ import ( "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" + "net/http" ) const ( @@ -956,7 +957,7 @@ func UpdateIssueStatus(ctx *context.Context) { for _, issue := range issues { if err := issue.ChangeStatus(ctx.User, issue.Repo, isClosed); err != nil { if models.IsErrDependenciesLeft(err) { - ctx.Error(409, "", fmt.Sprintf("cannot close this issue because it still has open dependencies")) + ctx.Error(http.StatusPreconditionFailed, "", fmt.Sprintf("cannot close this issue because it still has open dependencies")) return } ctx.ServerError("ChangeStatus", err) @@ -1026,10 +1027,10 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { if models.IsErrDependenciesLeft(err) { if issue.IsPull { ctx.Flash.Error(ctx.Tr("repo.issues.dependency.pr_close_blocked")) - ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index)) + ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index), http.StatusTemporaryRedirect) } else { ctx.Flash.Error(ctx.Tr("repo.issues.dependency.issue_close_blocked")) - ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index)) + ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issue.Index), http.StatusTemporaryRedirect) } } } else {