如何知道多个存储库已重命名的新名称?

问题描述 投票:1回答:1

我有一个应用程序,记录数据库中的一些GitHub存储库的名称。以下面的3个回购为例。

  1. https://github.com/zhangkun-Jser/react-experience
  2. https://github.com/zhangkun-Jser/vue-plug
  3. https://github.com/hsluoyz/casbin

但问题是我记录的回购可能会被重命名。例如,上面的三个repos分别被重命名为:

  1. https://github.com/zhangkun-Jser/react-kit
  2. https://github.com/zhangkun-Jser/FE-plugs
  3. https://github.com/casbin/casbin

我想编写一些代码来主动将任何旧的repo名称更新为我的数据库中的新repo名称。例如,将zhangkun-Jser/react-experience更新为zhangkun-Jser/react-kit

我知道我可以使用GitHub V3 API获取每个repo的存储库信息,然后获取新名称。但这需要发送每个回购请求。我的问题是if there is any method to get the new names for a list of repos in one request

注意:回购可以来自不同的所有者,如示例中所示。

我试图使用GraphQL API v4,但我不知道如何获取回购列表的信息。并且V4 API似乎无法识别旧名称。例如,如果我发送以下请求:

{
  repository(owner: "zhangkun-Jser" name: "react-experience") {
    name
    id
  }
}

回应是:

{
  "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
        }
      ]
    }
  ]
}

有人可以帮忙吗?谢谢。

github graphql github-api github-graphql
1个回答
1
投票

您可以存储存储库的节点ID并按ID查找节点:

query { 
  repository (owner:"osowskit", name:"about") { 
    id
  },
  node(id:"MDEwOlJlcG9zaXRvcnk1NjE2NzA2OQ") {
  ... on Repository {
      id,
      name,
      nameWithOwner
    }
  }
}
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.