-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
RepositoriesService.List is a bit different from most other go-github methods because it calls one of two endpoints depending on the options. When user == "" it calls GET /user/repos which returns all of the authenticated user's repos. When user != "" it calls GET /user/{username}/repos which returns only the public repos of the specified user regardless of the caller's permissions.
The current godoc1 alludes to this by listing multiple github doc links, but it is still unclear. The options struct2 adds to the confusion with the "affiliation" and "visibility" query parameters that are only available on /user/repos. It also lists "public" and "private" as options for the "type" parameter. Those are only available for /user/repos as well.
See #2980 for an example of this causing confusion.
Without looking at the history, I suspect these two endpoints used to be more similar and github added more options over time that made them diverge. So it made sense to combine these into one method, but if these were new endpoints now, they wouldn't have been combined into one endpoint.
I propose that we create two new methods: RepositoriesService.ListForUser and RepositoriesService.ListForAuthenticatedUser that makes this split explicit and update RepositoriesService.List's godoc to make the distinction clear. Maybe we should deprecate RepositoriesService.List as well.