GitHub API -
对于getRepos操作,您将获得用户存储库的列表。
返回的存储库对象中包含一些信息。但是,它们似乎没有关于“我从哪个存储库fork来”的任何信息?
我该如何获取这个信息?
对于getRepos操作,您将获得用户存储库的列表。
返回的存储库对象中包含一些信息。但是,它们似乎没有关于“我从哪个存储库fork来”的任何信息?
我该如何获取这个信息?
当仓库是 fork 时,会出现
parent
和source
对象:
parent
是这个 repo 被 fork 的源头,source
是网络的最终源头。
当我获取 git 仓库的 fork 时,我会看到:
curl -s "https://api.github.com/repos/VonC/git"
"parent": {
"id": 36502,
"name": "git",
"full_name": "git/git",
"owner": {
"login": "git",
"id": 18133,
您可以通过阅读parent字段的内容来获得分叉的repo信息。
parent
和source
字段的大小,GitHub可能已经将它们从列出给定用户的所有仓库的API调用中排除在外。 - VonC