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

Emi*_*aas 6 github-api pygithub

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

我知道

repo.get_commits() 
Run Code Online (Sandbox Code Playgroud)

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

Branch 类中也没有像 .get_commits() 这样的东西

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

Von*_*onC 6

正如这里所讨论的,这最终应该使用GitHub API List Commits

\n
get /repos/{owner}/{repo}/commits\n
Run Code Online (Sandbox Code Playgroud)\n

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

\n

Ib PyGitHub,即github.Repository.Repository.get_commits(),与sha \xe2\x80\x93 string是分支的名称。

\n

这将返回github.PaginatedList.PaginatedList一个github.Commit.Commit

\n