Incomplete repos when '/user/repos' url is used! #35

Closed
Chris2048 opened this Issue Oct 7, 2012 · 6 comments

Comments

Projects
None yet
3 participants

Any repos derived from getting a list of repos via the /user/repos url, and then turning the resulting json list into repo objects will be incomplete relative to fetching this information via the url given by repo.url (/repos/:user/:name).

I came across this when I used 'list_repos', and noticed that none of the repo objects had 'parent' or 'source' attributes.

Maybe repo objects can be made to fetch more json data via the self._api url, and update themselves?
Maybe then missing data attributes could be properties that execute this updater method?

My own quick-fix is to replace the last 'return' line of list_repos in github.py with:

return [Repository(self._json(self._get(repo['url']), 200), self) for repo in json]
Owner

sigmavirus24 commented Oct 7, 2012

The API does this in a large number of places. If you were to do:

from github3 import repository


r = repository('kennethreitz', 'requests')
u = next(r.iter_subscribers())
print u.login
print u.name
print u.html_url

The last two don't exist. I don't think making a second request each time is the best idea, but I'm entirely ok with adding a new method to these objects to retrieve all of the information. I just can't think of a clever name at the moment. Can you think of one? Also, would this be palatable?

Owner

sigmavirus24 commented Oct 7, 2012

@pengwynn is there any chance the API would be modified to include the whole thing? Is there a reason everything isn't included in the first place? For an endpoint like this, I'm a bit surprised that source and parent aren't included.

pengwynn commented Oct 8, 2012

Unfortunately we can't. Getting that info from Git is expensive so we only do it when you request a single repository.

Owner

sigmavirus24 commented Oct 8, 2012

Yeah, and I'd rather not forcibly tax the API by requesting everything each time, @Chris2048, so I'm going to lean towards adding methods to make this easier on you. Still not sure what a good name would be.

Owner

sigmavirus24 commented Oct 8, 2012

Also, thanks @pengwynn

Owner

sigmavirus24 commented Oct 14, 2012

Yeah, I guess I'm just going to go ahead and add a method refresh. To each one to retrieve the object's information again.

@sigmavirus24 sigmavirus24 added a commit that referenced this issue Oct 14, 2012

@sigmavirus24 sigmavirus24 Closes #35 1fcf8e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment