Skip to content

Instantly share code, notes, and snippets.

@mohierf
Created April 11, 2017 16:25
Show Gist options
  • Save mohierf/89f2a74635695d2e406329b8a7d058fd to your computer and use it in GitHub Desktop.
Save mohierf/89f2a74635695d2e406329b8a7d058fd to your computer and use it in GitHub Desktop.
Count commits for Alignak project
from github3 import login
from pprint import pprint
import operator
user, password = 'mohierf', 'my_password'
commits_count = 0
g = login(user, password=password)
organization = 'alignak-monitoring'
o = g.organization(organization)
my_stats = []
for r in o.iter_repos():
for c in r.iter_contributor_statistics():
if user in repr(c.author):
my_stats.append((r.name, c.total))
my_stats = sorted(my_stats, key=operator.itemgetter(1), reverse=True)
print("Contributions of the user '%s' in organization '%s':" % (user, organization))
for project, count in my_stats:
print(" - repo '%s', %d commits" % (project, count))
commits_count += count
organization = 'alignak-monitoring-contrib'
o = g.organization(organization)
my_stats = []
for r in o.iter_repos():
# print(r)
for c in r.iter_contributor_statistics():
if user in repr(c.author):
my_stats.append((r.name, c.total))
my_stats = sorted(my_stats, key=operator.itemgetter(1), reverse=True)
print("Contributions of the user '%s' in organization '%s':" % (user, organization))
for project, count in my_stats:
print(" - repo '%s', %d commits" % (project, count))
commits_count += count
print("Total commits of the user '%s' for Alignak: %d" % (user, commits_count))
@mohierf
Copy link
Author

mohierf commented Apr 11, 2017

Simple gist using github API to count the number of commits for all the repositories in alignak-monitoring and alignak-monitoring-contrib organizations 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment