如何在github中查找某个组织的所有提交?

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

目前 github 允许我找到存储库的提交,但在一个组织中有许多存储库使用下面的代码

 https://api.github.com/repos/OWNER/REPO/commits

我想找到所有存储库的总数,而不需要循环遍历并对它们求和。有没有更快的方法来获取组织的总提交

我对每个仓库都尝试了

 https://api.github.com/repos/OWNER/REPO/commits
,但运行时间很长,所以我想找到更好的替代方案。

github github-api commit repo github-organizations
1个回答
0
投票

更快的选择可能是使用 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 对每个提交进行分页要高效得多。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.