-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
fix: Admin can see all private repositories on Explore page. #1026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
models/repo.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a good idea to copy Session. I think you can use cond?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done e892404
models/repo.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count, err := x.Where(cond).Cound(new(Repository))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done e892404
LGTM |
conflicted |
fixed conflicts. |
} | ||
|
||
return repos, nil | ||
count = countRepositories(-1, opts.Private) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we check opts.Private
to see if we should include private repos, but when populating the repos
slice, we always include private repos regardless of opts.Private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repositories
always returns all repositories. maybe we need to change countRepositories(-1, true)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Repositories(..)
always returns all repositories, I think it is misleading for it to take a SearchRepoOptions
as a parameter, since it ignores most of the fields of opts
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can create another PR to refactor the codes according to your suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I suppose I could do it too. Either way, it's outside the scope of this PR.
|
||
// Repositories returns all repositories | ||
func Repositories(opts *SearchRepoOptions) (_ RepositoryList, err error) { | ||
func Repositories(opts *SearchRepoOptions) (_ RepositoryList, count int64, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDITED: Why does this function not examine the contents of opts.Searcher
, and exclude repos accordingly (like GetRecentUpdateRepositories(..)~
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need to examine the contents of opts.Searcher
?
https://github.com/go-gitea/gitea/blob/master/models/issue_indexer.go#L119
https://github.com/go-gitea/gitea/blob/master/routers/admin/repos.go#L28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant like GetRecentUpdateRepsitories(..)
; sorry if that caused any confusion.
Even if every codepath that calls Repositories(..)
has opts.Searcher
set to nil
, someone might in the future add a changes that calls Repositories(..)
, have opts.Searcher
not be nil
, and expect Repositories
to filter accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Repositories(..)
only looks at opts.PageSize
, opts.Page
, and opts.OrderBy
, would it be better to have it take those 3 values as separate arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO. I think using SearchRepoOptions
would be better than take 3 arguments if we want to extend the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
let L-G-T-M work @ethantkoenig Thanks for review this PR. |
let L-G-T-M work |
fix #1022
RepoSearchOptions