From a819be49ea4c046b848dafaade349274fde9c06e Mon Sep 17 00:00:00 2001 From: Lingzhu Xiang Date: Mon, 25 Jan 2016 09:33:19 -0500 Subject: [PATCH] tools: Add mkcontrib.py --- tools/mkcontrib.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tools/mkcontrib.py diff --git a/tools/mkcontrib.py b/tools/mkcontrib.py new file mode 100644 index 000000000..430404a84 --- /dev/null +++ b/tools/mkcontrib.py @@ -0,0 +1,26 @@ +# 1. Visual inspection: python mkcontrib.py +# 2. If OK, python mkcontrib.py | grep -v ^# > CONTRIB + +from subprocess import Popen, PIPE +from collections import defaultdict, Counter + +p = Popen(["git","log","--no-merges","--format=%aN <%aE>"], stdout=PIPE).stdout +common_email = defaultdict(Counter) +common_name = defaultdict(Counter) +for line in p: + author, email = line.rstrip().split('<') + common_email[author].update([email]) + common_name[email].update([author]) + +for email in common_name: + names = common_name[email] + names = sorted(names, key=lambda x: (names[x], len(x)), reverse=True) + for name in names[1:]: + common_email[names[0]] += common_email[name] + del common_email[name] + print '# Less common or shorter name', name, 'is replaced by', names[0] + +for name in sorted(common_email): + for k in common_email[name].most_common()[1:]: + print '# Less common email <' + k[0] + ' is removed.' + print name + '<' + common_email[name].most_common(1)[0][0]