forked from kevadesu/forgejo
Move pull request api convert to convert package (#9664)
* Move pull request api convert to convert package * Rename ToPullRequest to ToAPIPullRequest
This commit is contained in:
parent
8878cfa4a1
commit
384c2b342e
7 changed files with 198 additions and 160 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/auth"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
|
@ -102,7 +103,7 @@ func ListPullRequests(ctx *context.APIContext, form api.ListPullRequestsOptions)
|
|||
ctx.Error(http.StatusInternalServerError, "GetHeadRepo", err)
|
||||
return
|
||||
}
|
||||
apiPrs[i] = prs[i].APIFormat()
|
||||
apiPrs[i] = convert.ToAPIPullRequest(prs[i])
|
||||
}
|
||||
|
||||
ctx.SetLinkHeader(int(maxResults), models.ItemsPerPage)
|
||||
|
@ -157,7 +158,7 @@ func GetPullRequest(ctx *context.APIContext) {
|
|||
ctx.Error(http.StatusInternalServerError, "GetHeadRepo", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, pr.APIFormat())
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIPullRequest(pr))
|
||||
}
|
||||
|
||||
// CreatePullRequest does what it says
|
||||
|
@ -321,7 +322,7 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
|
|||
notification.NotifyNewPullRequest(pr)
|
||||
|
||||
log.Trace("Pull request created: %d/%d", repo.ID, prIssue.ID)
|
||||
ctx.JSON(http.StatusCreated, pr.APIFormat())
|
||||
ctx.JSON(http.StatusCreated, convert.ToAPIPullRequest(pr))
|
||||
}
|
||||
|
||||
// EditPullRequest does what it says
|
||||
|
@ -479,7 +480,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
|
|||
}
|
||||
|
||||
// TODO this should be 200, not 201
|
||||
ctx.JSON(http.StatusCreated, pr.APIFormat())
|
||||
ctx.JSON(http.StatusCreated, convert.ToAPIPullRequest(pr))
|
||||
}
|
||||
|
||||
// IsPullRequestMerged checks if a PR exists given an index
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue