我想知道在从 Github API 创建某个分支之前已经完成了多少次提交。
例如在 git cli 中我正在做:git log --no-merges --oneline ${branchHash} | wc -l
我可以看到这个数字。
Github API 的限制为 100,所以如果我有超过 100 次提交,我就无法全部获取。
对于这种情况有什么解决办法吗?
我写了一些东西来解决这个问题:
要点“从 GitHub API 计算提交计数的简单方法 https://gist.github.com/yershalom/a7c08f9441d1aadb13777bce4c7cdc3b".
它基于使用compare URL https://stackoverflow.com/a/26962188/6309 of the GitHub 提交 API https://docs.github.com/en/rest/commits/commits#compare-two-commits,并使用total_commits
field:
compare_url = '{}/repos/{}/{}/compare/{}...{}'.format(base_url, owner, repo, first_commit, sha)
commit_count = commit_req.json()['total_commits'] + 1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)