PyGithub - 如何获取特定分支的所有提交的列表?

时间:2021-05-13 12:12:03

标签: github-api pygithub

我需要检查对 github 上特定分支所做的所有提交。

我知道

repo.get_commits() 

但是我猜这会返回该存储库的所有分支的提交。我在 Commit classGitcommit class 中都没有找到任何分支属性。

Branch class 中也没有 .get_commits() 之类的东西

解决这个问题的正确方法是什么?

1 个答案:

答案 0 :(得分:2)

作为 discussed here,这应该最终使用 GitHub API List Commits

get /repos/{owner}/{repo}/commits

将要列出提交的 sha 或分支名称作为参数。

Ib PyGitHub,即 github.Repository.Repository.get_commits(),其中 sha – string 是分支的名称。

这将返回 github.PaginatedList.PaginatedListgithub.Commit.Commit