6

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?

Emil Haas
  • 484
  • 3
  • 17

1 Answers1

5

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

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Actually the link for the discussion does not work for me but your answer is complete so I actually do not need it anymore. Thanks – Emil Haas May 13 '21 at 13:23