|
#!/usr/bin/env python3 |
|
|
|
import collections |
|
import itertools |
|
import yaml |
|
|
|
from git import Repo |
|
|
|
repo = Repo("/Users/gaston/mesosphere/mesos") |
|
releases = ["1.0.0", "1.1.0", "1.2.0", "1.3.0", "1.4.0", "1.5.0-rc1"] |
|
|
|
with open("/Users/gaston/mesosphere/mesos/docs/contributors.yaml", 'r') as stream: |
|
contributors_info = yaml.load(stream) |
|
|
|
def contributors_per_org(): |
|
print("# Contributor Breakdown by Organization and Releases\n") |
|
|
|
authors_per_org_releases = collections.defaultdict(lambda: collections.defaultdict(set)) |
|
for index, release in enumerate(releases): |
|
if index == 0: |
|
continue |
|
|
|
refhead = releases[index - 1] + "..." + releases[index] |
|
|
|
commits = list(repo.iter_commits(refhead)) |
|
|
|
print("## " + refhead + ": " + str(len(commits)) + " commits") |
|
|
|
for commit in commits: |
|
author = {"name": commit.author.name} |
|
|
|
for contributor in contributors_info: |
|
if commit.author.email.lower() in contributor["emails"]: |
|
author = contributor |
|
break |
|
|
|
organization = "Other" |
|
if author and "affiliations" in author: |
|
organization = author["affiliations"][0]["organization"] |
|
|
|
authors_per_org_releases[release][organization].add(author["name"]) |
|
|
|
for k, v in authors_per_org_releases[release].items(): |
|
print("- " + k + ": " + str(len(v))) |
|
|
|
print("") |
|
|
|
def commits_per_org(): |
|
print("# Commit Breakdown by Organizations and Releases\n") |
|
|
|
commits_per_org_releases = collections.defaultdict(lambda: collections.defaultdict(int)) |
|
for index, release in enumerate(releases): |
|
if index == 0: |
|
continue |
|
|
|
refhead = releases[index - 1] + "..." + releases[index] |
|
|
|
commits = list(repo.iter_commits(refhead)) |
|
|
|
print("## " + refhead + ": " + str(len(commits)) + " commits") |
|
|
|
for commit in commits: |
|
for contributor in contributors_info: |
|
if commit.author.email.lower() in contributor["emails"]: |
|
author = contributor |
|
break |
|
|
|
organization = "Other" |
|
if author and "affiliations" in author: |
|
organization = author["affiliations"][0]["organization"] |
|
|
|
commits_per_org_releases[release][organization] += 1 |
|
|
|
for k, v in commits_per_org_releases[release].items(): |
|
print("- " + k + ": " + str(v) + " (" + format(v/len(commits)*100, "2.2f") + "%)") |
|
|
|
print("") |
|
|
|
contributors_per_org() |
|
commits_per_org() |