目前 github 允许我找到存储库的提交,但在一个组织中有许多存储库使用下面的代码
https://api.github.com/repos/OWNER/REPO/commits
我想找到所有存储库的总数,而不需要循环遍历并对它们求和。有没有更快的方法来获取组织的总提交
我对每个仓库都尝试了
https://api.github.com/repos/OWNER/REPO/commits
,但运行时间很长,所以我想找到更好的替代方案。
更快的选择可能是使用 Github API 列出组织的所有公共存储库,然后 仅使用 git clone --filter=object:type=commit
克隆提交。
这里有一些伪代码来解释。
num_commits = 0
for repo in org.repos
git clone --filter=object:type=commit repo.url
cd into repo
num_commits += git rev-list --all --count
这有可能非常高效,因为提交对象非常小并且克隆非常高效。比使用 JSON API 对每个提交进行分页要高效得多。