新增:重新打开pr接口

This commit is contained in:
yystopf 2025-06-23 19:26:16 +08:00
parent b015baf624
commit 8910972c65
3 changed files with 21 additions and 1 deletions

View File

@ -22,7 +22,7 @@ import (
)
var (
Version = "v2.8, by v1.21.0 "
Version = "v2.8.1, by v1.21.0 "
Tags = ""
MakeVersion = ""
)

View File

@ -188,6 +188,7 @@ func Routers() *web.Route {
m.Get("", repo.ListPullRequestVersions)
m.Get("/{versionId}/diff", context.ReferencesGitRepo(), repo.GetPullRequestVersionDiff)
})
m.Get("/change_status", repo.ChangePullRequestCloseStatus)
})
}, mustAllowPulls, reqRepoReader(unit_model.TypeCode), context.ReferencesGitRepo())
m.Group("/releases", func() {

View File

@ -35,6 +35,25 @@ import (
hat_pull_service "code.gitlink.org.cn/Gitlink/gitea_hat.git/services/pull"
)
func ChangePullRequestCloseStatus(ctx *context.APIContext) {
pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound()
} else {
ctx.Error(http.StatusInternalServerError, "GetPullRequestByIndex", err)
}
return
}
changeStatus := ctx.FormBool("is_closed")
_, err = issues_model.ChangeIssueStatus(ctx, pr.Issue, ctx.Doer, changeStatus)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ChangeIssueStatus", err)
}
ctx.Status(http.StatusNoContent)
}
func CreatePrVersion(ctx *context.APIContext) {
form := web.GetForm(ctx).(*gitea_api.PullRequestPayload)
hat_pull_service.AddToTaskQueue(&issues_model.PullRequest{ID: form.PullRequest.ID}, string(form.Action))