@@ -1184,25 +1184,23 @@ func CountUserRepositories(userID int64, private bool) int64 {
1184
1184
}
1185
1185
1186
1186
// Repositories returns all repositories
1187
- func Repositories (opts * SearchRepoOptions ) (_ [] * Repository , err error ) {
1187
+ func Repositories (opts * SearchRepoOptions ) (_ RepositoryList , err error ) {
1188
1188
if len (opts .OrderBy ) == 0 {
1189
1189
opts .OrderBy = "id ASC"
1190
1190
}
1191
1191
1192
- repos := make ([]* Repository , 0 , opts .PageSize )
1193
- return repos , x .Limit (opts .PageSize , (opts .Page - 1 )* opts .PageSize ).OrderBy (opts .OrderBy ).Find (& repos )
1194
- }
1192
+ repos := make (RepositoryList , 0 , opts .PageSize )
1195
1193
1196
- // RepositoriesWithUsers returns number of repos in given page .
1197
- func RepositoriesWithUsers (opts * SearchRepoOptions ) ( _ [] * Repository , err error ) {
1198
- repos , err := Repositories (opts )
1199
- if err != nil {
1200
- return nil , fmt .Errorf ("Repositories : %v" , err )
1194
+ if err = x .
1195
+ Limit (opts . PageSize , ( opts . Page - 1 ) * opts . PageSize ).
1196
+ OrderBy (opts . OrderBy ).
1197
+ Find ( & repos ); err != nil {
1198
+ return nil , fmt .Errorf ("Repo : %v" , err )
1201
1199
}
1202
1200
1203
- for i := range repos {
1204
- if err = repos [ i ]. GetOwner ( ); err != nil {
1205
- return nil , err
1201
+ if opts . Searcher != nil || opts . Starred {
1202
+ if err = repos . loadAttributes ( x ); err != nil {
1203
+ return nil , fmt . Errorf ( "LoadAttributes: %v" , err )
1206
1204
}
1207
1205
}
1208
1206
@@ -1716,7 +1714,7 @@ func GetUserMirrorRepositories(userID int64) ([]*Repository, error) {
1716
1714
}
1717
1715
1718
1716
// GetRecentUpdatedRepositories returns the list of repositories that are recently updated.
1719
- func GetRecentUpdatedRepositories (opts * SearchRepoOptions ) (repos [] * Repository , err error ) {
1717
+ func GetRecentUpdatedRepositories (opts * SearchRepoOptions ) (repos RepositoryList , err error ) {
1720
1718
if len (opts .OrderBy ) == 0 {
1721
1719
opts .OrderBy = "updated_unix DESC"
1722
1720
}
@@ -1739,9 +1737,19 @@ func GetRecentUpdatedRepositories(opts *SearchRepoOptions) (repos []*Repository,
1739
1737
}
1740
1738
}
1741
1739
1742
- return repos , sess .
1740
+ if err = sess .
1743
1741
OrderBy (opts .OrderBy ).
1744
- Find (& repos )
1742
+ Find (& repos ); err != nil {
1743
+ return nil , fmt .Errorf ("Repo: %v" , err )
1744
+ }
1745
+
1746
+ if opts .Searcher != nil || opts .Starred {
1747
+ if err = repos .loadAttributes (x ); err != nil {
1748
+ return nil , fmt .Errorf ("LoadAttributes: %v" , err )
1749
+ }
1750
+ }
1751
+
1752
+ return repos , nil
1745
1753
}
1746
1754
1747
1755
func getRepositoryCount (e Engine , u * User ) (int64 , error ) {
@@ -1848,7 +1856,7 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos RepositoryList, _ in
1848
1856
return nil , 0 , fmt .Errorf ("Repo: %v" , err )
1849
1857
}
1850
1858
1851
- if opts .Starred {
1859
+ if opts .Searcher != nil || opts . Starred {
1852
1860
if err = repos .loadAttributes (x ); err != nil {
1853
1861
return nil , 0 , fmt .Errorf ("LoadAttributes: %v" , err )
1854
1862
}
0 commit comments