-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
API: support '/orgs/:org/repos' #1691
Conversation
Please add swagger:route comment |
routers/api/v1/org/repo.go
Outdated
org := ctx.Org.Organization | ||
|
||
// Find all repos a user has access to within an org. | ||
reposEnv, err := org.AccessibleReposEnv(requester.ID) |
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.
Will 500 if user is not signed in. Think it's the same problem further down too, ctx.User = nil. See #1622
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.
Maybe you can add an integration test on integrations sub directory. There are some examples there.
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.
So I'm going to check for user being nil first, do want to reply 200 with an empty list if they aren't signed in?
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 will also add a test...was going to ask before PR was accepted where the appropriate place for that was :) When drone runs I notice a lot of places say they have no test files is that because they are all covered in integration tests or are those tests things that would be accepted as PRs?
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.
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 a user isn't logged in the request should still show public repos in said organization. So just returning an empty list here would not work 🙂
routers/api/v1/org/repo.go
Outdated
|
||
apiRepos := make([]*api.Repository, len(repos)) | ||
for i, repo := range repos { | ||
accessLevel, err := models.AccessLevel(requester.ID, repo) |
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.
Same here
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.
^
Please add tests for the new endpoint |
@@ -0,0 +1,46 @@ | |||
package org |
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.
Needs a copyright
// 500: error | ||
|
||
var apiRepos []*api.Repository | ||
if ctx.User != nil { |
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 don't like quietly returning a empty list of repositories for unauthenticated users. Either we should have a 401 (like we do for GET /repos/:owner/:reponame
), or show the unauthenticated users the organization's public repos.
Actually a feature that gogs has and gitea does not - gogs/gogs@cd9b29f#diff-2620fdbeeb83ce43692534e6c2c39452R230 - very much looking forward to it being added to gitea. |
So sorry this was added and then died. I've been busy with interviews and graduation but I'll have the rest of the issues with this fixed hopefully by Friday. |
instead by #2047 |
Fix for: #494