mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 14:44:35 -04:00
more context for models (#19511)
make more usage of context, to have more db transaction in one session (make diff of #9307 smaller)
This commit is contained in:
parent
332b2ecd21
commit
06e4687cec
54 changed files with 275 additions and 245 deletions
|
@ -7,6 +7,7 @@ package models
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
|
||||
|
@ -99,11 +100,14 @@ func TestRenameBranch(t *testing.T) {
|
|||
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
|
||||
_isDefault := false
|
||||
|
||||
err := UpdateProtectBranch(repo1, &ProtectedBranch{
|
||||
ctx, committer, err := db.TxContext()
|
||||
defer committer.Close()
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, UpdateProtectBranch(ctx, repo1, &ProtectedBranch{
|
||||
RepoID: repo1.ID,
|
||||
BranchName: "master",
|
||||
}, WhitelistOptions{})
|
||||
assert.NoError(t, err)
|
||||
}, WhitelistOptions{}))
|
||||
assert.NoError(t, committer.Commit())
|
||||
|
||||
assert.NoError(t, RenameBranch(repo1, "master", "main", func(isDefault bool) error {
|
||||
_isDefault = isDefault
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue