0

I would like to know how can one check that public git repository is updated or not (if their are new commits) using python. Help in this regard would be appreciated.

iq tech
  • 49
  • 3
  • 12

1 Answers1

0

PyGitHub is great for this, you can do something like:


for repo in g.get_organization(ORGANIZATION).get_repos():
        print(f"Processing {repo.full_name}...")
        commit_activity = repo.get_stats_commit_activity()

        # We have 52 weeks of commit history to total up
        annual_commits = 0
        for week in commit_activity:
            annual_commits += week.total

        print(f"Totalled {annual_commits} commits.")

https://pygithub.readthedocs.io/en/latest/github_objects/Repository.html#github.Repository.Repository.get_stats_commit_activity

Leslie Alldridge
  • 1,427
  • 1
  • 10
  • 26