Add context parameter to some database functions (#26055)

To avoid deadlock problem, almost database related functions should be
have ctx as the first parameter.
This PR do a refactor for some of these functions.
This commit is contained in:
Lunny Xiao 2023-07-22 22:14:27 +08:00 committed by GitHub
parent c42b71877e
commit b167f35113
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 209 additions and 237 deletions

View file

@ -10,6 +10,7 @@ import (
"testing"
"time"
"code.gitea.io/gitea/models/db"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/queue"
@ -36,7 +37,7 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
assert.NoError(t, err)
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2})
AddToTaskQueue(pr)
AddToTaskQueue(db.DefaultContext, pr)
assert.Eventually(t, func() bool {
pr = unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 2})