Commit 8fda64ee authored by Gustavo Padovan's avatar Gustavo Padovan

contribution-stats: add argparse and use current dir for the git tree

parent 75ac1a2d
#! /usr/bin/env python
from pygit2 import Repository, Tag
from pygit2 import GIT_SORT_TOPOLOGICAL
import sys
import argparse
import csv
import os
import sys
import re
details=True
GIT_TREE="/home/gfpadovan/p/linux"
from pygit2 import Repository, Tag
from pygit2 import GIT_SORT_TOPOLOGICAL
EMAIL_PATTERN = "@collabora.co"
CONTENT = " (?P<name>[\w\-\. ]+) <(?P<username>.*" + EMAIL_PATTERN + ".*)>"
......@@ -55,16 +54,22 @@ def is_maintainer(commit, email, name):
def total_commits(d):
return sum((v[0] for v in d.values()))
def print_commits(dict):
def print_commits(dict, args):
for email, data in sorted(dict.items(), key=lambda item: item[1], reverse=True):
print("%s <%s> %d" % (contributors[email], email, data[0]))
if details:
if not args.summary:
for c in data[1]:
print("\t%s %s" % (c[0][0:9], c[1]))
print("")
if __name__ == "__main__":
repo = Repository(GIT_TREE)
parser = argparse.ArgumentParser()
parser.set_defaults(func=lambda x: parser.print_help())
parser.add_argument('-s', '--summary', action='store_true',
help="enable details for each section")
args = parser.parse_args(sys.argv[1:])
repo = Repository(os.getcwd())
for line in csv.reader(sys.stdin, delimiter=','):
commit = repo.get(line[0])
if EMAIL_PATTERN in commit.author.email:
......@@ -93,22 +98,22 @@ if __name__ == "__main__":
add_commit(tag[1], m[1], commit)
print("# Authored (%d)\n" % total_commits(authored))
print_commits(authored)
print_commits(authored, args)
print("")
print("# Maintainer Committed (%d)\n" % total_commits(committed))
print_commits(committed)
print_commits(committed, args)
print("")
print("# Signed-off-by: (%d)\n" % total_commits(signed))
print_commits(signed)
print_commits(signed, args)
print("")
print("# On behalf of: (%d)\n" % total_commits(onbehalf))
print_commits(onbehalf)
print_commits(onbehalf, args)
print("")
for tag in OTHER_TAGS:
print("# %s (%d)\n" % (tag[0],total_commits(tag[1])))
print_commits(tag[1])
print_commits(tag[1], args)
print("")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment