1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-04 08:17:24 -05:00

Use RepositoryList instead of []*Repository (#25074)

This commit is contained in:
Lunny Xiao 2023-06-05 15:25:47 +08:00 committed by GitHub
parent ca35dec18b
commit 11598885b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 10 deletions

View File

@ -34,7 +34,7 @@ func (issues IssueList) getRepoIDs() []int64 {
} }
// LoadRepositories loads issues' all repositories // LoadRepositories loads issues' all repositories
func (issues IssueList) LoadRepositories(ctx context.Context) ([]*repo_model.Repository, error) { func (issues IssueList) LoadRepositories(ctx context.Context) (repo_model.RepositoryList, error) {
if len(issues) == 0 { if len(issues) == 0 {
return nil, nil return nil, nil
} }

View File

@ -710,8 +710,8 @@ func (org *Organization) GetUserTeams(userID int64) ([]*Team, error) {
type AccessibleReposEnvironment interface { type AccessibleReposEnvironment interface {
CountRepos() (int64, error) CountRepos() (int64, error)
RepoIDs(page, pageSize int) ([]int64, error) RepoIDs(page, pageSize int) ([]int64, error)
Repos(page, pageSize int) ([]*repo_model.Repository, error) Repos(page, pageSize int) (repo_model.RepositoryList, error)
MirrorRepos() ([]*repo_model.Repository, error) MirrorRepos() (repo_model.RepositoryList, error)
AddKeyword(keyword string) AddKeyword(keyword string)
SetSort(db.SearchOrderBy) SetSort(db.SearchOrderBy)
} }
@ -813,7 +813,7 @@ func (env *accessibleReposEnv) RepoIDs(page, pageSize int) ([]int64, error) {
Find(&repoIDs) Find(&repoIDs)
} }
func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*repo_model.Repository, error) { func (env *accessibleReposEnv) Repos(page, pageSize int) (repo_model.RepositoryList, error) {
repoIDs, err := env.RepoIDs(page, pageSize) repoIDs, err := env.RepoIDs(page, pageSize)
if err != nil { if err != nil {
return nil, fmt.Errorf("GetUserRepositoryIDs: %w", err) return nil, fmt.Errorf("GetUserRepositoryIDs: %w", err)
@ -842,7 +842,7 @@ func (env *accessibleReposEnv) MirrorRepoIDs() ([]int64, error) {
Find(&repoIDs) Find(&repoIDs)
} }
func (env *accessibleReposEnv) MirrorRepos() ([]*repo_model.Repository, error) { func (env *accessibleReposEnv) MirrorRepos() (repo_model.RepositoryList, error) {
repoIDs, err := env.MirrorRepoIDs() repoIDs, err := env.MirrorRepoIDs()
if err != nil { if err != nil {
return nil, fmt.Errorf("MirrorRepoIDs: %w", err) return nil, fmt.Errorf("MirrorRepoIDs: %w", err)

View File

@ -11,7 +11,7 @@ import (
) )
// GetOrgRepositories get repos belonging to the given organization // GetOrgRepositories get repos belonging to the given organization
func GetOrgRepositories(ctx context.Context, orgID int64) ([]*repo_model.Repository, error) { func GetOrgRepositories(ctx context.Context, orgID int64) (repo_model.RepositoryList, error) {
var orgRepos []*repo_model.Repository var orgRepos []*repo_model.Repository
return orgRepos, db.GetEngine(ctx).Where("owner_id = ?", orgID).Find(&orgRepos) return orgRepos, db.GetEngine(ctx).Where("owner_id = ?", orgID).Find(&orgRepos)
} }

View File

@ -346,7 +346,7 @@ func TestAccessibleReposEnv_Repos(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
repos, err := env.Repos(1, 100) repos, err := env.Repos(1, 100)
assert.NoError(t, err) assert.NoError(t, err)
expectedRepos := make([]*repo_model.Repository, len(expectedRepoIDs)) expectedRepos := make(repo_model.RepositoryList, len(expectedRepoIDs))
for i, repoID := range expectedRepoIDs { for i, repoID := range expectedRepoIDs {
expectedRepos[i] = unittest.AssertExistsAndLoadBean(t, expectedRepos[i] = unittest.AssertExistsAndLoadBean(t,
&repo_model.Repository{ID: repoID}) &repo_model.Repository{ID: repoID})
@ -365,7 +365,7 @@ func TestAccessibleReposEnv_MirrorRepos(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
repos, err := env.MirrorRepos() repos, err := env.MirrorRepos()
assert.NoError(t, err) assert.NoError(t, err)
expectedRepos := make([]*repo_model.Repository, len(expectedRepoIDs)) expectedRepos := make(repo_model.RepositoryList, len(expectedRepoIDs))
for i, repoID := range expectedRepoIDs { for i, repoID := range expectedRepoIDs {
expectedRepos[i] = unittest.AssertExistsAndLoadBean(t, expectedRepos[i] = unittest.AssertExistsAndLoadBean(t,
&repo_model.Repository{ID: repoID}) &repo_model.Repository{ID: repoID})

View File

@ -37,7 +37,7 @@ type SearchTeamRepoOptions struct {
} }
// GetRepositories returns paginated repositories in team of organization. // GetRepositories returns paginated repositories in team of organization.
func GetTeamRepositories(ctx context.Context, opts *SearchTeamRepoOptions) ([]*repo_model.Repository, error) { func GetTeamRepositories(ctx context.Context, opts *SearchTeamRepoOptions) (repo_model.RepositoryList, error) {
sess := db.GetEngine(ctx) sess := db.GetEngine(ctx)
if opts.TeamID > 0 { if opts.TeamID > 0 {
sess = sess.In("id", sess = sess.In("id",

View File

@ -115,7 +115,7 @@ func GitGcRepo(ctx context.Context, repo *repo_model.Repository, timeout time.Du
return nil return nil
} }
func gatherMissingRepoRecords(ctx context.Context) ([]*repo_model.Repository, error) { func gatherMissingRepoRecords(ctx context.Context) (repo_model.RepositoryList, error) {
repos := make([]*repo_model.Repository, 0, 10) repos := make([]*repo_model.Repository, 0, 10)
if err := db.Iterate( if err := db.Iterate(
ctx, ctx,