-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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' #2047
Conversation
build fail. |
routers/api/v1/user/repo.go
Outdated
// 200: RepositoryList | ||
// 500: error | ||
|
||
org := GetOrgByParams(ctx) |
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.
Not necessary, can just use ctx.Org
(which is populated by the orgAssignment(true)
handler)
I think build failure is due to the added test case. I need to make an org inside the integrations test somehow but wasn't sure of how to do that. Any guidance would be helpful |
integrations/api_repo_test.go
Outdated
func TestAPIOrgReposNotLogin(t *testing.T) { | ||
assert.NoError(t, models.LoadFixtures()) | ||
|
||
req := NewRequest(t, "GET", "/api/v1/orgs/org1/repos") |
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.
@awwalker You need to be authenticated for this API endpoint; that's why the test is failing. Use the loginUser(..)
helper function, and take a look at other API integrations test (a lot of them already use loginUser(..)
).
routers/api/v1/user/repo.go
Outdated
// 200: RepositoryList | ||
// 500: error | ||
|
||
listUserRepos(ctx, ctx.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.
ctx.Org.Organization
must be used
@awwalker See https://github.com/go-gitea/gitea/blob/master/models/fixtures/user.yml, |
integrations/api_repo_test.go
Outdated
req := NewRequest(t, "GET", "/api/v1/orgs/user3/repos") | ||
session := loginUser(t, "user2") | ||
resp := session.MakeRequest(t, req) | ||
assert.EqualValues(t, http.StatusOK, resp.HeaderCode) |
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 check also if it returns correct repository count
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
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.
A little corner case to check and a little simplification. For the rest LGTM.
// 200: RepositoryList | ||
// 500: error | ||
|
||
listUserRepos(ctx, ctx.Org.Organization) |
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.
I have made a PR #2117 to enforce that ctx.Org.Organization is an org. So this detail could be ignore and the check up under /users/{username}/repo could be make in another PR.
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.
Awesome thanks
routers/api/v1/api.go
Outdated
@@ -455,6 +455,9 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
m.Combo("/:username").Get(org.IsMember). | |||
Delete(reqToken(), reqOrgOwnership(), org.DeleteMember) | |||
}) | |||
m.Group("/repos", func() { |
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 a group for only one route ? Just do m.Get("/repos", user.ListOrgRepos).
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.
Just as a side note during review context we should use a combo and migrate https://github.com/go-gitea/gitea/blob/master/routers/api/v1/api.go#L335 that does not currently follow the normal path. Still, this will maybe break few things so I will wait for the advice of other before doing that. Maybe in an other PR.
integrations/api_repo_test.go
Outdated
@@ -10,6 +10,7 @@ import ( | |||
|
|||
"code.gitea.io/gitea/models" | |||
|
|||
api "code.gitea.io/sdk/gitea" |
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.
Should be next to other code.gitea.io
imports (see the styleguide)
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.
Hm this was gofmt's choice because I aliased it. I'll edit it for the styleguide though
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.
This should pass drone once #2125 is in |
@ethantkoenig rebased and ready for review |
@awwalker Conflicts again |
@bkcsoft better....for now! |
LGTM |
LGTM |
This is in favor of #1691 in order to fix #494.
Sorry for opening a new PR, but this new approach seems to address all of the concerns brought up in #494. I also added an integration test, but was unsure of how to create a test organization in the integrations directory. If this PR is approved of over #494 I'll close that one and we can focus on this one. Otherwise I'll go back to fixing that one and close this one.