Skip to content

Commit 159d3e1

Browse files
committed
fix issue search bug
1 parent f189e84 commit 159d3e1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

models/issues/issue_search.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func applyRepoConditions(sess *xorm.Session, opts *IssuesOptions) *xorm.Session
202202
if opts.RepoCond == nil {
203203
opts.RepoCond = builder.NewCond()
204204
}
205-
opts.RepoCond = opts.RepoCond.Or(builder.In("issue.repo_id", builder.Select("id").From("repository").Where(builder.Eq{"is_private": false})))
205+
opts.RepoCond = opts.RepoCond.Or(repo_model.PublicRepoCond("issue.repo_id"))
206206
}
207207
if opts.RepoCond != nil {
208208
sess.And(opts.RepoCond)
@@ -340,6 +340,7 @@ func issuePullAccessibleRepoCond(repoIDstr string, userID int64, org *organizati
340340
} else {
341341
cond = cond.And(
342342
builder.Or(
343+
repo_model.PublicRepoCond(repoIDstr), // all public repos
343344
repo_model.UserOwnedRepoCond(userID), // owned repos
344345
repo_model.UserAccessRepoCond(repoIDstr, userID), // user can access repo in a unit independent way
345346
repo_model.UserAssignedRepoCond(repoIDstr, userID), // user has been assigned accessible public repos

models/repo/repo_list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ const (
229229
SearchOrderByForksReverse SearchOrderBy = "num_forks DESC"
230230
)
231231

232+
func PublicRepoCond(id string) builder.Cond {
233+
return builder.In(id, builder.Select("id").From("repository").Where(builder.Eq{"is_private": false}))
234+
}
235+
232236
// UserOwnedRepoCond returns user ownered repositories
233237
func UserOwnedRepoCond(userID int64) builder.Cond {
234238
return builder.Eq{

0 commit comments

Comments
 (0)