I have an application that records the names of some GitHub repositories in database. Take the following 3 repos for example.
- https://github.com/zhangkun-Jser/react-experience
- https://github.com/zhangkun-Jser/vue-plug
- https://github.com/hsluoyz/casbin
But the issue is the repos I recorded may be renamed. For example, the above three repos have been respectively renamed to:
- https://github.com/zhangkun-Jser/react-kit
- https://github.com/zhangkun-Jser/FE-plugs
- https://github.com/casbin/casbin
I want to write some code to actively update any old repo names to new repo names in my database. For example, update zhangkun-Jser/react-experience
to zhangkun-Jser/react-kit
.
I know I can use GitHub V3 API
to get the repository info for every repo and then get the new name. But this requires to send a request for every repo. My question is if there is any method to get the new names for a list of repos in one request
?
Note: The repos can be from different owners, like in the example.
I tried to use the GraphQL API v4
but I didn't know how to get the info of a list of repos. And the V4 API seems not to recognize the old names. For example, if I send the following request:
{
repository(owner: "zhangkun-Jser" name: "react-experience") {
name
id
}
}
The response is:
{
"data": {
"repository": null
},
"errors": [
{
"message": "Could not resolve to a Repository with the name 'react-experience'.",
"type": "NOT_FOUND",
"path": [
"repository"
],
"locations": [
{
"line": 2,
"column": 3
}
]
}
]
}
Anyone can help? Thanks.