Emil Haas
Emil Haas

Reputation: 734

PyGithub - How to get a list of all commits for a particular branch?

I need to check all commits made to a particular branch on github.

I am aware of

repo.get_commits() 

but this returns commits for all branches of that repository I guess. I haven't found any branch attribute neither in Commit class nor in Gitcommit class.

Also there is not sth like .get_commits() in Branch class

What is the proper way to solve this problem?

Upvotes: 6

Views: 4340

Answers (1)

VonC
VonC

Reputation: 1323803

As discussed here, this should utimately use the GitHub API List Commits

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

With as parameter the sha or branch name from which you want to list commits.

Ib PyGitHub, that is github.Repository.Repository.get_commits(), with sha – string being the name of the branch.

That will return a github.PaginatedList.PaginatedList of github.Commit.Commit

Upvotes: 6

Related Questions