aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo/fork.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-01-15 10:19:25 +0800
committerGitHub <noreply@github.com>2024-01-15 02:19:25 +0000
commit70c4aad8e1cbc46b049b015dcd6f2e5be5a69e72 (patch)
tree5c9f049437c1a84a402aeef3be0cb4b95dea667e /models/repo/fork.go
parente5313248a8ed967a915f072d3991b6d046badf02 (diff)
downloadgitea-70c4aad8e1cbc46b049b015dcd6f2e5be5a69e72.tar.gz
gitea-70c4aad8e1cbc46b049b015dcd6f2e5be5a69e72.zip
Move more functions to db.Find (#28419)
Following #28220 This PR move more functions to use `db.Find`. --------- Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'models/repo/fork.go')
-rw-r--r--models/repo/fork.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/models/repo/fork.go b/models/repo/fork.go
index 6be6ebc3f5..07cd31c269 100644
--- a/models/repo/fork.go
+++ b/models/repo/fork.go
@@ -56,13 +56,16 @@ func GetUserFork(ctx context.Context, repoID, userID int64) (*Repository, error)
// GetForks returns all the forks of the repository
func GetForks(ctx context.Context, repo *Repository, listOptions db.ListOptions) ([]*Repository, error) {
+ sess := db.GetEngine(ctx)
+
+ var forks []*Repository
if listOptions.Page == 0 {
- forks := make([]*Repository, 0, repo.NumForks)
- return forks, db.GetEngine(ctx).Find(&forks, &Repository{ForkID: repo.ID})
+ forks = make([]*Repository, 0, repo.NumForks)
+ } else {
+ forks = make([]*Repository, 0, listOptions.PageSize)
+ sess = db.SetSessionPagination(sess, &listOptions)
}
- sess := db.GetPaginatedSession(&listOptions)
- forks := make([]*Repository, 0, listOptions.PageSize)
return forks, sess.Find(&forks, &Repository{ForkID: repo.ID})
}