CodeTriage
CodeTriage copied to clipboard
Auto Migrate redirected repos
When a repo moves, move the users:
http://www.codetriage.com/defunkt/resque => http://www.codetriage.com/resque/resque
Maybe give a "migrate" this repo button of some kind where it puts your request in a manual queue or opens a github issue or something.
I could have sworn this was an open issue, but I cannot find it ATM.
How to detect if a repo is moved or not?
Does github gives the indication in the response?
I think the open issue is #228
I looked into this recently and with the help of Github support found two ways of doing this:
(1) The non-API 'hacky' route (guess which one of us came up with this idea :smile:)
Although the API doesn't redirect on repository or user, github.com
does. For example, 6to5/6to5
was recently renamed to babel/babel
. Running curl -I https://api.github.com/repos/6to5/6to5
returns a 404. However, running curl -I https://github.com/6to5/6to5
returns a 301 with a Location
field that points to the new location.
So, one alternative is to rescue GitHubBub::RequestError
with a HEAD
request to github.com
, grab the new Location
, massage that into an API request to the renamed repo, and update everything accordingly.
I think this would be a viable solution if there were no way to do this through the API, but Ivan from Github support showed me what may be a better alternative.
(2) The API route less travelled
All repositories and users have numerical IDs that uniquely identify them — we've just had no reason to store them...until maybe now. If we were to store them, then you could use that to ensure you get the same repository regardless of what it is named.
Take babel/babel
again whose repo ID is 24560307
. Knowing this, curl -i https://api.github.com/repositories/24560307
will always give us that repo even if it were renamed to Isomorphic/MonadicArrow
tomorrow. Only if it were deleted (or maybe if it went private) would you run into problems.
You could use this same idea to solve the name switching bug mentioned in issue #301, too, using a call to https://api.github.com/user/:id
.
Anyway, let me know your thoughts when you have time. I'd love to take a crack at solving this.
Cheers, O-I
@O-I Awesome work. :+1: I think second approach is best.
OK. I'll look into going that route then.
:wave:
Is there any update or workaround for this? I wouldn't wanna introduce duplication but I just moved PragTob/benchee to bencheeorg/benchee and would like to know how to best proceed :D
Still needed
Fixed on #1722 Can we close this issue?