Skip to content

Fix GET /users/:username/repos endpoint #2125

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

Merged
merged 1 commit into from
Jul 10, 2017

Conversation

ethantkoenig
Copy link
Member

@ethantkoenig ethantkoenig commented Jul 7, 2017

Fixes the following bugs in the GET /users/:username/repos endpoint:

  • Used to get 500 if user was unauthenticated
  • Used to indicate that requester has owner-level access of repos owned by :username, regardless of whether this was actually true
  • Used to display the repositories that the authenticated user (not the searched user) had access to. Ideally, it should display neither, but like Github only display repos that the searched user owns.

Also improve existing integration tests to check that responses are expected.

@ethantkoenig ethantkoenig changed the title Fix GET /users/:username/repo endpoint Fix GET /users/:username/repos endpoint Jul 7, 2017
Copy link
Contributor

@awwalker awwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to combine these like they were before with an explicit check for ctx.User being equal to the user passed in? And only when they are equal displaying accessibleRepos as well as ownRepos? It feels like theres a lot of recycled code...

@ethantkoenig
Copy link
Member Author

@awwalker No, because GET /users/:username/repos should not return accessible repos, even if you search for yourself. Accessible repos should only be returned by the GET /user/repos endpoint. We'll still be able to share the code in listUserRepos(..) between the GET /users/:username/repos and GET orgs/:orgname/repos endpoints.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 8, 2017
@awwalker
Copy link
Contributor

awwalker commented Jul 8, 2017

@ethantkoenig Hm ok I am confused as to why not then. Can you explain please?

@ethantkoenig
Copy link
Member Author

@awwalker The canned answer: because that's how Github's API is, and we try to match the Github API as closely as possible

My longer answer: which seems like a cleaner and more concise specification?

  1. GET /users/:username/repos: Returns the repos that :username owns
  2. GET /users/:username/repos: Returns the repos that :username owns. In (only) the case where the requester is authenticated as :username, the repos that :username does not own but has access to are also included

There is already an endpoint for listing the repos that you have access to (GET /user/repos), so we should avoid unnecessarily complicating the behavior of the GET /users/:username/repos endpoint.

@awwalker
Copy link
Contributor

awwalker commented Jul 8, 2017

@ethantkoenig Awesome. Thanks for going above the canned response! And I see how this is still usable for orgs.

@sapk
Copy link
Member

sapk commented Jul 10, 2017

With a quick overview and addition of tests I trust you for LGTM.

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 10, 2017
@lunny lunny added this to the 1.2.0 milestone Jul 10, 2017
@lunny lunny added the type/bug label Jul 10, 2017
@lunny
Copy link
Member

lunny commented Jul 10, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 10, 2017
@lafriks lafriks merged commit 8f1d62a into go-gitea:master Jul 10, 2017
@ethantkoenig ethantkoenig deleted the fix/api branch July 10, 2017 22:32

type searchResponseBody struct {
ok bool
data []api.Repository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't use un-exported values in decode function.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants