mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00: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:
@@ -106,7 +106,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||
|
||||
repo.IsPrivate = opts.GitPushOptions.Bool(private.GitPushOptionRepoPrivate, repo.IsPrivate)
|
||||
repo.IsTemplate = opts.GitPushOptions.Bool(private.GitPushOptionRepoTemplate, repo.IsTemplate)
|
||||
if err := repo_model.UpdateRepositoryCols(repo, "is_private", "is_template"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, repo, "is_private", "is_template"); err != nil {
|
||||
log.Error("Failed to Update: %s/%s Error: %v", ownerName, repoName, err)
|
||||
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
|
||||
Err: fmt.Sprintf("Failed to Update: %s/%s Error: %v", ownerName, repoName, err),
|
||||
@@ -141,7 +141,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||
continue
|
||||
}
|
||||
|
||||
pr, err := models.GetPullRequestByIndex(repo.ID, pullIndex)
|
||||
pr, err := models.GetPullRequestByIndex(ctx, repo.ID, pullIndex)
|
||||
if err != nil && !models.IsErrPullRequestNotExist(err) {
|
||||
log.Error("Failed to get PR by index %v Error: %v", pullIndex, err)
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
|
@@ -155,7 +155,7 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID, refFullN
|
||||
return
|
||||
}
|
||||
|
||||
protectBranch, err := models.GetProtectedBranchBy(repo.ID, branchName)
|
||||
protectBranch, err := models.GetProtectedBranchBy(ctx, repo.ID, branchName)
|
||||
if err != nil {
|
||||
log.Error("Unable to get protected branch: %s in %-v Error: %v", branchName, repo, err)
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
|
@@ -25,7 +25,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
|
||||
return
|
||||
}
|
||||
|
||||
deployKey, err := asymkey_model.GetDeployKeyByRepo(keyID, repoID)
|
||||
deployKey, err := asymkey_model.GetDeployKeyByRepo(ctx, keyID, repoID)
|
||||
if err != nil {
|
||||
if asymkey_model.IsErrDeployKeyNotExist(err) {
|
||||
ctx.PlainText(http.StatusOK, "success")
|
||||
@@ -52,7 +52,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
|
||||
func AuthorizedPublicKeyByContent(ctx *context.PrivateContext) {
|
||||
content := ctx.FormString("content")
|
||||
|
||||
publicKey, err := asymkey_model.SearchPublicKeyByContent(content)
|
||||
publicKey, err := asymkey_model.SearchPublicKeyByContent(ctx, content)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
Err: err.Error(),
|
||||
|
@@ -44,7 +44,7 @@ func SendEmail(ctx *context.PrivateContext) {
|
||||
var emails []string
|
||||
if len(mail.To) > 0 {
|
||||
for _, uname := range mail.To {
|
||||
user, err := user_model.GetUserByName(uname)
|
||||
user, err := user_model.GetUserByName(ctx, uname)
|
||||
if err != nil {
|
||||
err := fmt.Sprintf("Failed to get user information: %v", err)
|
||||
log.Error(err)
|
||||
|
@@ -109,7 +109,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
results.RepoName = repoName[:len(repoName)-5]
|
||||
}
|
||||
|
||||
owner, err := user_model.GetUserByName(results.OwnerName)
|
||||
owner, err := user_model.GetUserByName(ctx, results.OwnerName)
|
||||
if err != nil {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
// User is fetching/cloning a non-existent repository
|
||||
@@ -230,7 +230,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
var user *user_model.User
|
||||
if key.Type == asymkey_model.KeyTypeDeploy {
|
||||
var err error
|
||||
deployKey, err = asymkey_model.GetDeployKeyByRepo(key.ID, repo.ID)
|
||||
deployKey, err = asymkey_model.GetDeployKeyByRepo(ctx, key.ID, repo.ID)
|
||||
if err != nil {
|
||||
if asymkey_model.IsErrDeployKeyNotExist(err) {
|
||||
ctx.JSON(http.StatusNotFound, private.ErrServCommand{
|
||||
@@ -345,7 +345,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
|
||||
// We already know we aren't using a deploy key
|
||||
if !repoExist {
|
||||
owner, err := user_model.GetUserByName(ownerName)
|
||||
owner, err := user_model.GetUserByName(ctx, ownerName)
|
||||
if err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, private.ErrServCommand{
|
||||
Results: results,
|
||||
|
Reference in New Issue
Block a user