|
|
@ -1570,7 +1570,7 @@ func GetRepositoryCount(u *User) (int64, error) { |
|
|
|
type SearchRepoOptions struct { |
|
|
|
type SearchRepoOptions struct { |
|
|
|
Keyword string |
|
|
|
Keyword string |
|
|
|
OwnerID int64 |
|
|
|
OwnerID int64 |
|
|
|
UserID int64 // if set results will contain all public/private repositories user has access to
|
|
|
|
UserID int64 // When set results will contain all public/private repositories user has access to
|
|
|
|
OrderBy string |
|
|
|
OrderBy string |
|
|
|
Private bool // Include private repositories in results
|
|
|
|
Private bool // Include private repositories in results
|
|
|
|
Page int |
|
|
|
Page int |
|
|
@ -1591,21 +1591,21 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, _ int |
|
|
|
|
|
|
|
|
|
|
|
repos = make([]*Repository, 0, opts.PageSize) |
|
|
|
repos = make([]*Repository, 0, opts.PageSize) |
|
|
|
sess := x.Alias("repo") |
|
|
|
sess := x.Alias("repo") |
|
|
|
// Attempt to find repositories that opts.UserId has access to
|
|
|
|
// Attempt to find repositories that opts.UserID has access to,
|
|
|
|
// This does not include other people's private repositories even if opts.UserId is an admin
|
|
|
|
// this does not include other people's private repositories even if opts.UserID is an admin.
|
|
|
|
if !opts.Private && opts.UserID > 0 { |
|
|
|
if !opts.Private && opts.UserID > 0 { |
|
|
|
sess.Join("LEFT", "access", "access.repo_id = repo.id") |
|
|
|
sess.Join("LEFT", "access", "access.repo_id = repo.id"). |
|
|
|
sess.Where("repo.lower_name LIKE ? AND (repo.owner_id=? OR access.user_id=? OR repo.is_private=?)", |
|
|
|
Where("repo.lower_name LIKE ? AND (repo.owner_id = ? OR access.user_id = ? OR repo.is_private = ?)", |
|
|
|
"%"+opts.Keyword+"%", opts.UserID, opts.UserID, false) |
|
|
|
"%"+opts.Keyword+"%", opts.UserID, opts.UserID, false) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
sess.Where("repo.lower_name LIKE ?", "%"+opts.Keyword+"%") |
|
|
|
sess.Where("repo.lower_name LIKE ?", "%"+opts.Keyword+"%") |
|
|
|
// only return public repositories if opts.Private is not set
|
|
|
|
// Only return public repositories if opts.Private is not set
|
|
|
|
if !opts.Private { |
|
|
|
if !opts.Private { |
|
|
|
sess.And("repo.is_private=?", false) |
|
|
|
sess.And("repo.is_private = ?", false) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if opts.OwnerID > 0 { |
|
|
|
if opts.OwnerID > 0 { |
|
|
|
sess.And("repo.owner_id=?", opts.OwnerID) |
|
|
|
sess.And("repo.owner_id = ?", opts.OwnerID) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var countSess xorm.Session |
|
|
|
var countSess xorm.Session |
|
|
|