From 08ae0dd74be0e35753c2ac6cbf3196f5bfd18b58 Mon Sep 17 00:00:00 2001 From: James Date: Sat, 16 Jun 2018 09:34:55 +0100 Subject: [PATCH] repo: show in search if any part is public (#5234) if repo is private but wiki and/or issue are public show repo in search --- models/repo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/repo.go b/models/repo.go index 58bc8da8b..3efb36356 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1653,11 +1653,11 @@ func SearchRepositoryByName(opts *SearchRepoOptions) (repos []*Repository, count // this does not include other people's private repositories even if opts.UserID is an admin. if !opts.Private && opts.UserID > 0 { sess.Join("LEFT", "access", "access.repo_id = repo.id"). - Where("(repo.owner_id = ? OR access.user_id = ? OR repo.is_private = ?)", opts.UserID, opts.UserID, false) + Where("(repo.owner_id = ? OR access.user_id = ? OR repo.is_private = ? OR (repo.is_private = ? AND (repo.allow_public_wiki = ? OR repo.allow_public_issues = ?)))", opts.UserID, opts.UserID, false, true, true, true) } else { // Only return public repositories if opts.Private is not set if !opts.Private { - sess.And("repo.is_private = ?", false) + sess.And("(repo.is_private = ? OR (repo.is_private = ? AND (repo.allow_public_wiki = ? OR repo.allow_public_issues = ?))", false, true, true, true) } } if len(opts.Keyword) > 0 {