通过 Github API 列出 Github 存储库的依赖项

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

Github 网页在每个存储库的见解页面上显示了哪些存储库依赖于它: https://github.com/django/django/network/dependents

通过 Github API,您似乎只能获得您的存储库所依赖的存储库,而不是依赖于您的存储库的存储库。参见

Repository.dependencyGraphManifests
https://docs.github.com/en/graphql/reference/objects#repository

我错过了什么,还是无法通过 API 获取家属?

dependencies repository project github-api
1个回答
2
投票

当然,您可以安装 github-dependents-info 并像其他 API 一样在 Python 脚本中使用它。

例如以下脚本:

from github_dependents_info.gh_dependents_info import GithubDependentsInfo
import json

gh_deps_info = GithubDependentsInfo(
            'aimhubio/aim',
            debug=False,
            sort_key='name',
            min_stars=0,
            json_output=True,
            badge_markdown_file=False,
            badge_color='informational',
            merge_packages=True,
        )

dependents = gh_deps_info.collect()
with open('aim_dependents.json', 'w') as f:
    json.dump(dependents, f, indent=4)

相当于CLI命令:

github-dependents-info --repo aimhubio/aim -p -j > "aim_dependents.json"

尝试一下并给我一个赞!

© www.soinside.com 2019 - 2024. All rights reserved.