aboutsummaryrefslogtreecommitdiffstats
path: root/modules/doctor
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-10-31 23:51:14 +0800
committerGitHub <noreply@github.com>2022-10-31 23:51:14 +0800
commit9a70a12a341b8e7773efc661693e4b7e3199a4bd (patch)
tree2e4f3e18315ef52e68d4bfea5939d5517d3ca56b /modules/doctor
parent4ae3f762177a2cdb449b949501420e88462f8f95 (diff)
downloadgitea-9a70a12a341b8e7773efc661693e4b7e3199a4bd.tar.gz
gitea-9a70a12a341b8e7773efc661693e4b7e3199a4bd.zip
Merge db.Iterate and IterateObjects (#21641)
These two functions are similiar, merge them.
Diffstat (limited to 'modules/doctor')
-rw-r--r--modules/doctor/breaking.go5
-rw-r--r--modules/doctor/fix16961.go5
-rw-r--r--modules/doctor/mergebase.go5
-rw-r--r--modules/doctor/misc.go5
4 files changed, 7 insertions, 13 deletions
diff --git a/modules/doctor/breaking.go b/modules/doctor/breaking.go
index 51122d9a61..474997acd8 100644
--- a/modules/doctor/breaking.go
+++ b/modules/doctor/breaking.go
@@ -18,10 +18,9 @@ import (
func iterateUserAccounts(ctx context.Context, each func(*user.User) error) error {
err := db.Iterate(
ctx,
- new(user.User),
builder.Gt{"id": 0},
- func(idx int, bean interface{}) error {
- return each(bean.(*user.User))
+ func(ctx context.Context, bean *user.User) error {
+ return each(bean)
},
)
return err
diff --git a/modules/doctor/fix16961.go b/modules/doctor/fix16961.go
index 307cfcd9ff..d9f895739f 100644
--- a/modules/doctor/fix16961.go
+++ b/modules/doctor/fix16961.go
@@ -269,13 +269,10 @@ func fixBrokenRepoUnits16961(ctx context.Context, logger log.Logger, autofix boo
err := db.Iterate(
ctx,
- new(RepoUnit),
builder.Gt{
"id": 0,
},
- func(idx int, bean interface{}) error {
- unit := bean.(*RepoUnit)
-
+ func(ctx context.Context, unit *RepoUnit) error {
bs := unit.Config
repoUnit := &repo_model.RepoUnit{
ID: unit.ID,
diff --git a/modules/doctor/mergebase.go b/modules/doctor/mergebase.go
index b279c453f7..9f5e336461 100644
--- a/modules/doctor/mergebase.go
+++ b/modules/doctor/mergebase.go
@@ -21,10 +21,9 @@ import (
func iteratePRs(ctx context.Context, repo *repo_model.Repository, each func(*repo_model.Repository, *issues_model.PullRequest) error) error {
return db.Iterate(
ctx,
- new(issues_model.PullRequest),
builder.Eq{"base_repo_id": repo.ID},
- func(idx int, bean interface{}) error {
- return each(repo, bean.(*issues_model.PullRequest))
+ func(ctx context.Context, bean *issues_model.PullRequest) error {
+ return each(repo, bean)
},
)
}
diff --git a/modules/doctor/misc.go b/modules/doctor/misc.go
index 277d66a177..6f0e066f54 100644
--- a/modules/doctor/misc.go
+++ b/modules/doctor/misc.go
@@ -30,10 +30,9 @@ import (
func iterateRepositories(ctx context.Context, each func(*repo_model.Repository) error) error {
err := db.Iterate(
ctx,
- new(repo_model.Repository),
builder.Gt{"id": 0},
- func(idx int, bean interface{}) error {
- return each(bean.(*repo_model.Repository))
+ func(ctx context.Context, bean *repo_model.Repository) error {
+ return each(bean)
},
)
return err