Reputation: 8652
After I have renamed a private GitHub repo from foo/bar
to foo/qux
via the UI, if I try to get
https://api.github.com/repos/foo/qux
I get a 404.
If I request via the old name (https://api.github.com/repos/foo/bar) I get a redirect. But in general I don't have the previous repository names to work with so that's not an option.
The best solution I can think of is to get https://api.github.com/user/repos
, page through all the repos and find the repo named foo/qux
. But this sucks, and I'm sure the GitHub UI is not doing this when I go to https://github.com/foo/qux
. So is there an easier way to get the ID of the repo now named foo/qux
?
Upvotes: 1
Views: 184
Reputation: 8652
It appears the GitHub API will respond with a redirect for the old private repository name even if you don't have permission to read the repository itself (which is why I was getting a 404 when I requested it by its new name or even its numeric ID).
This led me to mistakenly conclude that the API knew about the old name but not the new name.
Select the "Full control of private repositories" scope on the personal auth token and you should be able to request a private repository by its new name.
Upvotes: 1
Reputation: 1323953
I get a 404.
From "example-repository-redirects.md" and the official blog post "Automatic redirects for renamed repositories" (July 2015), you shouldn't.
Try again after a few hours, in case it was 404 only just after a rename.
But the ID of the repo now named foo/qux
should be... foo/qux
.
Which means you should not need to find its old name.
Upvotes: 1