1

Using pygithub how to get latest commit on specific branch in a repo equivalent to github rest api https://{github.com}/api/v3/repos/{repo/}/{org}/commits/{branch}?per_page=1 I followed the steps mentioned in pygithub - Receive all commits of a specific branch , It's returning null.

branches = repo.get_branches() for branch in branches: print(branch.name) commits = repo.get_commits(path="tree/"+branch.name) for commit in commits: print(commit)

1 Answers1

0

Considering PyGithub/PyGithub issue 1967, try get_commit or branch.commit, first, for a single branch:

branches = repo.get_branches()
  for branch in branches:
    print("branch.last_modified: " + str(branch.last_modified))
    print("branch.commit: " + str(branch.commit))
    HEAD = repo.get_commit( str(branch.commit.sha))
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250