Created
April 11, 2017 16:25
-
-
Save mohierf/89f2a74635695d2e406329b8a7d058fd to your computer and use it in GitHub Desktop.
Count commits for Alignak project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple gist using github API to count the number of commits for all the repositories in
alignak-monitoring
andalignak-monitoring-contrib
organizations 😉