diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-12-11 16:56:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 16:56:48 +0800 |
commit | 537fa6996214ef42348cfe89bab6f2e04380aeac (patch) | |
tree | 2b1d7a5b05b5da1c2cd30f400fd3ca648729c6f5 /modules | |
parent | 0abb5633e34fd14c2d49de0b4c98f7ba7d98a37e (diff) | |
download | gitea-537fa6996214ef42348cfe89bab6f2e04380aeac.tar.gz gitea-537fa6996214ef42348cfe89bab6f2e04380aeac.zip |
Second part of refactor `db.Find` (#28194)
Continue of #27798 and move more functions to `db.Find` and `db.Count`.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/context/repo.go | 6 | ||||
-rw-r--r-- | modules/repository/branch.go | 8 |
2 files changed, 5 insertions, 9 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index f91dd6aa9a..a18dc873b6 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -668,11 +668,9 @@ func RepoAssignment(ctx *Context) context.CancelFunc { branchOpts := git_model.FindBranchOptions{ RepoID: ctx.Repo.Repository.ID, IsDeletedBranch: util.OptionalBoolFalse, - ListOptions: db.ListOptions{ - ListAll: true, - }, + ListOptions: db.ListOptionsAll, } - branchesTotal, err := git_model.CountBranches(ctx, branchOpts) + branchesTotal, err := db.Count[git_model.Branch](ctx, branchOpts) if err != nil { ctx.ServerError("CountBranches", err) return cancel diff --git a/modules/repository/branch.go b/modules/repository/branch.go index 8daceecb44..cd45f16227 100644 --- a/modules/repository/branch.go +++ b/modules/repository/branch.go @@ -49,11 +49,9 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, dbBranches := make(map[string]*git_model.Branch) { - branches, err := git_model.FindBranches(ctx, git_model.FindBranchOptions{ - ListOptions: db.ListOptions{ - ListAll: true, - }, - RepoID: repo.ID, + branches, err := db.Find[git_model.Branch](ctx, git_model.FindBranchOptions{ + ListOptions: db.ListOptionsAll, + RepoID: repo.ID, }) if err != nil { return 0, err |