refactor: use ctx in models

This commit is contained in:
Jason Song
2022-12-06 14:15:48 +08:00
parent c07d0c1768
commit 56368f3963
14 changed files with 87 additions and 165 deletions

View File

@@ -118,7 +118,7 @@ func List(ctx *context.Context) {
run.Repo = ctx.Repo.Repository
}
if err := runs.LoadTriggerUser(); err != nil {
if err := runs.LoadTriggerUser(ctx); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
return
}

View File

@@ -5,6 +5,7 @@ package actions
import (
"context"
"errors"
"fmt"
"net/http"
"time"
@@ -14,6 +15,7 @@ import (
"code.gitea.io/gitea/modules/actions"
context_module "code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web"
actions_service "code.gitea.io/gitea/services/actions"
@@ -271,7 +273,7 @@ func Cancel(ctx *context_module.Context) {
func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*actions_model.ActionRunJob, []*actions_model.ActionRunJob) {
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
if _, ok := err.(actions_model.ErrRunNotExist); ok {
if errors.Is(err, util.ErrNotExist) {
ctx.Error(http.StatusNotFound, err.Error())
return nil, nil
}