mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-18 08:00:01 +02:00
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
This commit is contained in:
parent
d81e31ad78
commit
fd7d83ace6
232 changed files with 1463 additions and 2108 deletions
|
@ -61,7 +61,7 @@ func ListPullReviews(ctx *context.APIContext) {
|
|||
// "404":
|
||||
// "$ref": "#/responses/notFound"
|
||||
|
||||
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
if models.IsErrPullRequestNotExist(err) {
|
||||
ctx.NotFound("GetPullRequestByIndex", err)
|
||||
|
@ -87,7 +87,7 @@ func ListPullReviews(ctx *context.APIContext) {
|
|||
IssueID: pr.IssueID,
|
||||
}
|
||||
|
||||
allReviews, err := models.FindReviews(opts)
|
||||
allReviews, err := models.FindReviews(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
|
@ -307,7 +307,7 @@ func CreatePullReview(ctx *context.APIContext) {
|
|||
// "$ref": "#/responses/validationError"
|
||||
|
||||
opts := web.GetForm(ctx).(*api.CreatePullReviewOptions)
|
||||
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
if models.IsErrPullRequestNotExist(err) {
|
||||
ctx.NotFound("GetPullRequestByIndex", err)
|
||||
|
@ -526,7 +526,7 @@ func preparePullReviewType(ctx *context.APIContext, pr *models.PullRequest, even
|
|||
|
||||
// prepareSingleReview return review, related pull and false or nil, nil and true if an error happen
|
||||
func prepareSingleReview(ctx *context.APIContext) (*models.Review, *models.PullRequest, bool) {
|
||||
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
if models.IsErrPullRequestNotExist(err) {
|
||||
ctx.NotFound("GetPullRequestByIndex", err)
|
||||
|
@ -536,7 +536,7 @@ func prepareSingleReview(ctx *context.APIContext) (*models.Review, *models.PullR
|
|||
return nil, nil, true
|
||||
}
|
||||
|
||||
review, err := models.GetReviewByID(ctx.ParamsInt64(":id"))
|
||||
review, err := models.GetReviewByID(ctx, ctx.ParamsInt64(":id"))
|
||||
if err != nil {
|
||||
if models.IsErrReviewNotExist(err) {
|
||||
ctx.NotFound("GetReviewByID", err)
|
||||
|
@ -648,7 +648,7 @@ func DeleteReviewRequests(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions, isAdd bool) {
|
||||
pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||
if err != nil {
|
||||
if models.IsErrPullRequestNotExist(err) {
|
||||
ctx.NotFound("GetPullRequestByIndex", err)
|
||||
|
@ -676,7 +676,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions
|
|||
if strings.Contains(r, "@") {
|
||||
reviewer, err = user_model.GetUserByEmail(r)
|
||||
} else {
|
||||
reviewer, err = user_model.GetUserByName(r)
|
||||
reviewer, err = user_model.GetUserByName(ctx, r)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -727,7 +727,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions
|
|||
teamReviewers := make([]*organization.Team, 0, len(opts.TeamReviewers))
|
||||
for _, t := range opts.TeamReviewers {
|
||||
var teamReviewer *organization.Team
|
||||
teamReviewer, err = organization.GetTeam(ctx.Repo.Owner.ID, t)
|
||||
teamReviewer, err = organization.GetTeam(ctx, ctx.Repo.Owner.ID, t)
|
||||
if err != nil {
|
||||
if organization.IsErrTeamNotExist(err) {
|
||||
ctx.NotFound("TeamNotExist", fmt.Sprintf("Team '%s' not exist", t))
|
||||
|
@ -892,7 +892,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss bool) {
|
|||
return
|
||||
}
|
||||
|
||||
if review, err = models.GetReviewByID(review.ID); err != nil {
|
||||
if review, err = models.GetReviewByID(ctx, review.ID); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetReviewByID", err)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue